![]() |
paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
|
#include <ssl_options.h>
Public Types | |
using | ptr_t = std::shared_ptr< ssl_options > |
using | const_ptr_t = std::shared_ptr< const ssl_options > |
using | unique_ptr_t = std::unique_ptr< ssl_options > |
using | error_handler = std::function< void(const string &errMsg)> |
using | psk_handler = std::function< unsigned(const string &hint, char *identity, size_t max_identity_len, unsigned char *psk, size_t max_psk_len)> |
Public Member Functions | |
ssl_options () | |
ssl_options (const string &trustStore, const string &keyStore, const string &privateKey, const string &privateKeyPassword, const string &enabledCipherSuites, bool enableServerCertAuth, const std::vector< string > alpnProtos=std::vector< string >()) | |
ssl_options (const string &trustStore, const string &keyStore, const string &privateKey, const string &privateKeyPassword, const string &caPath, const string &enabledCipherSuites, bool enableServerCertAuth, const std::vector< string > alpnProtos=std::vector< string >()) | |
ssl_options (const ssl_options &opt) | |
ssl_options (ssl_options &&opt) | |
ssl_options & | operator= (const ssl_options &opt) |
ssl_options & | operator= (ssl_options &&opt) |
string | get_trust_store () const |
string | get_key_store () const |
string | get_private_key () const |
string | get_private_key_password () const |
string | get_enabled_cipher_suites () const |
bool | get_enable_server_cert_auth () const |
void | set_trust_store (const string &trustStore) |
void | set_key_store (const string &keyStore) |
void | set_private_key (const string &privateKey) |
void | set_private_key_password (const string &privateKeyPassword) |
void | set_enabled_cipher_suites (const string &enabledCipherSuites) |
void | set_enable_server_cert_auth (bool enableServerCertAuth) |
int | get_ssl_version () const |
void | set_ssl_version (int ver) |
bool | get_verify () const |
void | set_verify (bool v) |
string | get_ca_path () const |
string | ca_path () const |
void | set_ca_path (const string &path) |
void | ca_path (const string &path) |
void | set_error_handler (error_handler cb) |
void | set_psk_handler (psk_handler cb) |
std::vector< string > | get_alpn_protos () const |
void | set_alpn_protos (const std::vector< string > &protos) |
Friends | |
class | connect_options |
Holds the set of SSL options for connection.
using mqtt::ssl_options::ptr_t = std::shared_ptr<ssl_options> |
Smart/shared pointer to an object of this class.
using mqtt::ssl_options::const_ptr_t = std::shared_ptr<const ssl_options> |
Smart/shared pointer to a const object of this class.
using mqtt::ssl_options::unique_ptr_t = std::unique_ptr<ssl_options> |
Unique pointer to an object of this class.
using mqtt::ssl_options::error_handler = std::function<void(const string& errMsg)> |
Handler type for error message callbacks
using mqtt::ssl_options::psk_handler = std::function<unsigned(const string& hint, char *identity, size_t max_identity_len, unsigned char *psk, size_t max_psk_len)> |
Handler type for TLS-PSK option callback. On success, the callback should return the length of the PSK (in bytes). On failure, it should throw or return zero.
mqtt::ssl_options::ssl_options | ( | ) |
Constructs a new MqttConnectOptions object using the default values.
mqtt::ssl_options::ssl_options | ( | const string & | trustStore, |
const string & | keyStore, | ||
const string & | privateKey, | ||
const string & | privateKeyPassword, | ||
const string & | enabledCipherSuites, | ||
bool | enableServerCertAuth, | ||
const std::vector< string > | alpnProtos = std::vector< string >() |
||
) |
Argument constructor.
trustStore | The file containing the public digital certificates trusted by the client. |
keyStore | The file containing the public certificate chain of the client. |
privateKey | The file containing the client's private key. |
privateKeyPassword | The password to load the client's privateKey if encrypted. |
enabledCipherSuites | The list of cipher suites that the client will present to the server during the SSL handshake. |
enableServerCertAuth | True/False option to enable verification of the server certificate |
alpnProtos | The ALPN protocols to try. |
mqtt::ssl_options::ssl_options | ( | const string & | trustStore, |
const string & | keyStore, | ||
const string & | privateKey, | ||
const string & | privateKeyPassword, | ||
const string & | caPath, | ||
const string & | enabledCipherSuites, | ||
bool | enableServerCertAuth, | ||
const std::vector< string > | alpnProtos = std::vector< string >() |
||
) |
Argument constructor.
trustStore | The file containing the public digital certificates trusted by the client. |
keyStore | The file containing the public certificate chain of the client. |
privateKey | The file containing the client's private key. |
privateKeyPassword | The password to load the client's privateKey if encrypted. |
caPath | The name of a directory containing CA certificates in PEM format. |
enabledCipherSuites | The list of cipher suites that the client will present to the server during the SSL handshake. |
enableServerCertAuth | True/False option to enable verification of the server certificate |
alpnProtos | The ALPN protocols to try. |
mqtt::ssl_options::ssl_options | ( | const ssl_options & | opt | ) |
Copy constructor.
opt | The other options to copy. |
mqtt::ssl_options::ssl_options | ( | ssl_options && | opt | ) |
Move constructor.
opt | The other options to move to this one. |
ssl_options& mqtt::ssl_options::operator= | ( | const ssl_options & | opt | ) |
Copy assignment.
opt | The other options to copy. |
ssl_options& mqtt::ssl_options::operator= | ( | ssl_options && | opt | ) |
Move assignment.
opt | The other options to move to this one. |
|
inline |
Expose the underlying C struct for the unit tests. Returns the file containing the public digital certificates trusted by the client.
|
inline |
Returns the file containing the public certificate chain of the client.
|
inline |
Gets the name of file containing the client's private key.
|
inline |
Gets the password to load the client's privateKey if encrypted.
|
inline |
Returns the list of cipher suites that the client will present to the server during the SSL handshake.
|
inline |
Returns the true/false to enable verification of the server certificate .
void mqtt::ssl_options::set_trust_store | ( | const string & | trustStore | ) |
Sets the file containing the public digital certificates trusted by the client.
trustStore | The file in PEM format containing the public digital certificates trusted by the client. |
void mqtt::ssl_options::set_key_store | ( | const string & | keyStore | ) |
Sets the file containing the public certificate chain of the client.
keyStore | The file in PEM format containing the public certificate chain of the client. It may also include the client's private key. |
void mqtt::ssl_options::set_private_key | ( | const string & | privateKey | ) |
Sets the file containing the client's private key.
privateKey | If not included in the sslKeyStore, this is the file in PEM format containing the client's private key. |
void mqtt::ssl_options::set_private_key_password | ( | const string & | privateKeyPassword | ) |
Sets the password to load the client's privateKey if encrypted.
privateKeyPassword | The password to load the privateKey if encrypted. |
void mqtt::ssl_options::set_enabled_cipher_suites | ( | const string & | enabledCipherSuites | ) |
Sets the list of cipher suites that the client will present to the server during the SSL handshake.
enabledCipherSuites | The list of cipher suites that the client will present to the server during the SSL handshake. For a full explanation of the cipher list format, please see the OpenSSL on-line documentation: http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT If this setting is omitted, its default value will be "ALL", that is, all the cipher suites -excluding those offering no encryption- will be considered. This setting can be used to set an SSL anonymous connection (empty string value, for instance). |
void mqtt::ssl_options::set_enable_server_cert_auth | ( | bool | enableServerCertAuth | ) |
Enables or disables verification of the server certificate.
enableServerCertAuth | enable/disable verification of the server certificate |
|
inline |
Gets the requested SSL/TLS version.
|
inline |
Set the SSL/TLS version to use.
ver | The desired SSL/TLS version. Specify one of:
|
|
inline |
Determines whether it will carry out post-connect checks, including that a certificate matches the given host name.
|
inline |
Sets whether it should carry out post-connect checks, including that a certificate matches the given host name.
v | Whether it should carry out post-connect checks. |
|
inline |
Gets the path to a directory containing CA certificates in PEM format.
|
inline |
void mqtt::ssl_options::set_ca_path | ( | const string & | path | ) |
Sets the path to a directory containing CA certificates in PEM format.
path | Path to a directory containing CA certificates in PEM format. |
|
inline |
void mqtt::ssl_options::set_error_handler | ( | error_handler | cb | ) |
Registers the error message callback handler.
cb | The callback to receive error messages. |
void mqtt::ssl_options::set_psk_handler | ( | psk_handler | cb | ) |
Registers a callback handler to set the TLS-PSK options. See: OpenSSL SSL_CTX_set_psk_client_callback()
cb | The callback. |
std::vector<string> mqtt::ssl_options::get_alpn_protos | ( | ) | const |
Gets the list of supported ALPN protocols.
void mqtt::ssl_options::set_alpn_protos | ( | const std::vector< string > & | protos | ) |
Sets the list of supported ALPN protocols. See: https://www.openssl.org/docs/man1.1.0/man3/SSL_CTX_set_alpn_protos.html
protos | The list of ALPN protocols to be negotiated. |
|
friend |
The connect options has special access