Loading...
Searching...
No Matches
mqtt::ssl_options Class Reference

`#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

## 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

## Detailed Description

Holds the set of SSL options for connection.

## Member Typedef Documentation

## ptr_t

using mqtt::ssl_options::ptr_t = std::shared_ptr<ssl_options>

Smart/shared pointer to an object of this class.

## const_ptr_t

using mqtt::ssl_options::const_ptr_t = std::shared_ptr<const ssl_options>

Smart/shared pointer to a const object of this class.

## unique_ptr_t

using mqtt::ssl_options::unique_ptr_t = std::unique_ptr<ssl_options>

Unique pointer to an object of this class.

## error_handler

using mqtt::ssl_options::error_handler = std::function<void(const string& errMsg)>

Handler type for error message callbacks

## psk_handler

using mqtt::ssl_options::psk_handler

Initial value:
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.

## Constructor & Destructor Documentation

## ssl_options() [1/5]

mqtt::ssl_options::ssl_options | ( |  | ) |

inline

Constructs a new MqttConnectOptions object using the default values.

## ssl_options() [2/5]

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.

Parameters

  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.

## ssl_options() [3/5]

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.

Parameters

  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.

## ssl_options() [4/5]

mqtt::ssl_options::ssl_options | ( | const ssl_options & | opt | ) |

Copy constructor.

Parameters

  opt | The other options to copy.

## ssl_options() [5/5]

mqtt::ssl_options::ssl_options | ( | ssl_options && | opt | ) |

Move constructor.

Parameters

  opt | The other options to move to this one.

## Member Function Documentation

## operator=() [1/2]

ssl_options & mqtt::ssl_options::operator= | ( | const ssl_options & | opt | ) |

Copy assignment.

Parameters

  opt | The other options to copy.

Returns
  A reference to this object.

## operator=() [2/2]

ssl_options & mqtt::ssl_options::operator= | ( | ssl_options && | opt | ) |

Move assignment.

Parameters

  opt | The other options to move to this one.

Returns
  A reference to this object.

## get_trust_store()

string mqtt::ssl_options::get_trust_store | ( |  | ) | const

inline

Expose the underlying C struct for the unit tests. Returns the file containing the public digital certificates trusted by the client.

Returns
  string

## get_key_store()

string mqtt::ssl_options::get_key_store | ( |  | ) | const

inline

Returns the file containing the public certificate chain of the client.

Returns
  string

## get_private_key()

string mqtt::ssl_options::get_private_key | ( |  | ) | const

inline

Gets the name of file containing the client's private key.

Returns
  The name of file containing the client's private key.

## get_private_key_password()

string mqtt::ssl_options::get_private_key_password | ( |  | ) | const

inline

Gets the password to load the client's privateKey if encrypted.

Returns
  The password to load the client's privateKey if encrypted.

## get_enabled_cipher_suites()

string mqtt::ssl_options::get_enabled_cipher_suites | ( |  | ) | const

inline

Returns the list of cipher suites that the client will present to the server during the SSL handshake.

Returns
  string

## get_enable_server_cert_auth()

bool mqtt::ssl_options::get_enable_server_cert_auth | ( |  | ) | const

inline

Returns the true/false to enable verification of the server certificate .

Returns
  bool

## set_trust_store()

void mqtt::ssl_options::set_trust_store | ( | const string & | trustStore | ) |

Sets the file containing the public digital certificates trusted by the client.

Parameters

  trustStore | The file in PEM format containing the public digital certificates trusted by the client.

## set_key_store()

void mqtt::ssl_options::set_key_store | ( | const string & | keyStore | ) |

Sets the file containing the public certificate chain of the client.

Parameters

  keyStore | The file in PEM format containing the public certificate chain of the client. It may also include the client's private key.

## set_private_key()

void mqtt::ssl_options::set_private_key | ( | const string & | privateKey | ) |

Sets the file containing the client's private key.

Parameters

  privateKey | If not included in the sslKeyStore, this is the file in PEM format containing the client's private key.

## set_private_key_password()

void mqtt::ssl_options::set_private_key_password | ( | const string & | privateKeyPassword | ) |

Sets the password to load the client's privateKey if encrypted.

Parameters

  privateKeyPassword | The password to load the privateKey if encrypted.

## set_enabled_cipher_suites()

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.

Parameters

  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: https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html 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).

## set_enable_server_cert_auth()

void mqtt::ssl_options::set_enable_server_cert_auth | ( | bool | enableServerCertAuth | ) |

Enables or disables verification of the server certificate.

Parameters

  enableServerCertAuth | enable/disable verification of the server certificate

## get_ssl_version()

int mqtt::ssl_options::get_ssl_version | ( |  | ) | const

inline

Gets the requested SSL/TLS version.

Returns
  The requested SSL/TLS version.

## set_ssl_version()

void mqtt::ssl_options::set_ssl_version | ( | int | ver | ) |

inline

Set the SSL/TLS version to use.

Parameters

  ver

  The desired SSL/TLS version. Specify one of:
  - MQTT_SSL_VERSION_DEFAULT (0)
  - MQTT_SSL_VERSION_TLS_1_0 (1)
  - MQTT_SSL_VERSION_TLS_1_1 (2)
  - MQTT_SSL_VERSION_TLS_1_2 (3)

## get_verify()

bool mqtt::ssl_options::get_verify | ( |  | ) | const

inline

Determines whether it will carry out post-connect checks, including that a certificate matches the given host name.

Returns
  Whether it will carry out post-connect checks.

## set_verify()

void mqtt::ssl_options::set_verify | ( | bool | v | ) |

inline

Sets whether it should carry out post-connect checks, including that a certificate matches the given host name.

Parameters

  v | Whether it should carry out post-connect checks.

## get_ca_path()

string mqtt::ssl_options::get_ca_path | ( |  | ) | const

inline

Gets the path to a directory containing CA certificates in PEM format.

Returns
  Path to a directory containing CA certificates in PEM format, if set. If this isn't set, returns an empty string.

## ca_path() [1/2]

string mqtt::ssl_options::ca_path | ( |  | ) | const

inline

## set_ca_path()

void mqtt::ssl_options::set_ca_path | ( | const string & | path | ) |

Sets the path to a directory containing CA certificates in PEM format.

Parameters

  path | Path to a directory containing CA certificates in PEM format.

## ca_path() [2/2]

void mqtt::ssl_options::ca_path | ( | const string & | path | ) |

inline

## set_error_handler()

void mqtt::ssl_options::set_error_handler | ( | error_handler | cb | ) |

Registers the error message callback handler.

Parameters

  cb | The callback to receive error messages.

## set_psk_handler()

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()

Parameters

  cb | The callback.

## get_alpn_protos()

std::vector< string > mqtt::ssl_options::get_alpn_protos | ( |  | ) | const

Gets the list of supported ALPN protocols.

Returns
  A vector containing the supported ALPN protocols.

## set_alpn_protos()

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

Parameters

  protos | The list of ALPN protocols to be negotiated.

## Friends And Related Symbol Documentation

## connect_options

friend class connect_options

friend

The connect options has special access

The documentation for this class was generated from the following file:

- ssl_options.h