boost::corosio::tls_context::set_password_callback
Set the password callback for encrypted keys.
Synopsis
Declared in <boost/corosio/tls_context.hpp>
template<typename Callback>
void
set_password_callback(Callback callback);
Description
Installs a callback that provides passwords for encrypted private keys and PKCS#12 files. The callback is invoked when loading encrypted key material.
Example
ctx.set_password_callback(
[]( std::size_t max_len, tls_password_purpose purpose )
{
// In practice, prompt user or read from secure storage
return std::string( "my-key-password" );
});
// Now load encrypted key
ctx.use_private_key_file( "encrypted.key", tls_file_format::pem );
Template Parameters
| Name | Description |
|---|---|
Callback |
A callable with signature |
Parameters
| Name | Description |
|---|---|
callback |
The password callback. It receives the maximum password length and the purpose (reading or writing), and returns the password string. |
See Also
tls_password_purpose
Created with MrDocs