SSLManager
SSLManager
#include <icy/net/sslmanager.h>Singleton that owns the default client/server TLS contexts and related callbacks.
Public Attributes
| Return | Name | Description |
|---|---|---|
ThreadSignal< void(VerificationErrorDetails &)> | ServerVerificationError | Fired whenever a certificate verification error is detected by the server during a handshake. |
ThreadSignal< void(VerificationErrorDetails &)> | ClientVerificationError | Fired whenever a certificate verification error is detected by the client during a handshake. |
ThreadSignal< void(std::string &)> | PrivateKeyPassphraseRequired | Fired when an encrypted certificate or private key is loaded. Not setting the password in the event parameter will result in a failure to load the certificate. |
ServerVerificationError
ThreadSignal< void(VerificationErrorDetails &)> ServerVerificationErrorFired whenever a certificate verification error is detected by the server during a handshake.
ClientVerificationError
ThreadSignal< void(VerificationErrorDetails &)> ClientVerificationErrorFired whenever a certificate verification error is detected by the client during a handshake.
PrivateKeyPassphraseRequired
ThreadSignal< void(std::string &)> PrivateKeyPassphraseRequiredFired when an encrypted certificate or private key is loaded. Not setting the password in the event parameter will result in a failure to load the certificate.
Public Methods
| Return | Name | Description |
|---|---|---|
void | initializeServer | Initializes the server side of the SSLManager server-side SSLContext. |
void | initializeClient | Initializes the client side of the SSLManager with a default client-side SSLContext. |
SSLContext::Ptr | defaultServerContext | Returns the default context used by the server if initialized. |
SSLContext::Ptr | defaultClientContext | Returns the default context used by the client if initialized. |
void | shutdown | Shuts down the SSLManager and releases the default context objects. After a call to shutdown(), the SSLManager can no longer be used. |
initializeServer
void initializeServer(SSLContext::Ptr ptrContext)Initializes the server side of the SSLManager server-side SSLContext.
initializeClient
void initializeClient(SSLContext::Ptr ptrContext)Initializes the client side of the SSLManager with a default client-side SSLContext.
defaultServerContext
SSLContext::Ptr defaultServerContext()Returns the default context used by the server if initialized.
defaultClientContext
SSLContext::Ptr defaultClientContext()Returns the default context used by the client if initialized.
shutdown
void shutdown()Shuts down the SSLManager and releases the default context objects. After a call to shutdown(), the SSLManager can no longer be used.
Normally, it's not necessary to call this method directly, as this will be called either by uninitializeSSL(), or when the SSLManager instance is destroyed.
Public Static Methods
| Return | Name | Description |
|---|---|---|
SSLManager & | instance static | Returns the instance of the SSLManager singleton. |
void | destroy static | Shuts down and destroys the SSLManager singleton instance. |
void | initNoVerifyClient static | Initializes a default no-verify client context that's useful for testing. |
void | initNoVerifyServer static | Initializes a default no-verify server context that's useful for testing. Optionally accepts private key and certificate file paths for server identity; if omitted, no certificate is loaded. |
instance
static
static SSLManager & instance()Returns the instance of the SSLManager singleton.
destroy
static
static void destroy()Shuts down and destroys the SSLManager singleton instance.
initNoVerifyClient
static
static void initNoVerifyClient()Initializes a default no-verify client context that's useful for testing.
initNoVerifyServer
static
static void initNoVerifyServer(const std::string & privateKeyFile, const std::string & certificateFile)Initializes a default no-verify server context that's useful for testing. Optionally accepts private key and certificate file paths for server identity; if omitted, no certificate is loaded.
Private Attributes
| Return | Name | Description |
|---|---|---|
SSLContext::Ptr | _defaultServerContext | |
SSLContext::Ptr | _defaultClientContext | |
std::mutex | _mutex |
_defaultServerContext
SSLContext::Ptr _defaultServerContext_defaultClientContext
SSLContext::Ptr _defaultClientContext_mutex
std::mutex _mutexPrivate Methods
| Return | Name | Description |
|---|---|---|
SSLManager | Creates the SSLManager. | |
~SSLManager | Destroys the SSLManager. | |
SSLManager | Deleted constructor. | |
SSLManager | Deleted constructor. |
SSLManager
SSLManager()Creates the SSLManager.
~SSLManager
~SSLManager() noexceptDestroys the SSLManager.
SSLManager
SSLManager(const SSLManager &) = deleteDeleted constructor.
SSLManager
SSLManager(SSLManager &&) = deleteDeleted constructor.
Private Static Methods
| Return | Name | Description |
|---|---|---|
int | verifyCallback static | The return value of this method defines how errors in verification are handled. Return 0 to terminate the handshake, or 1 to continue despite the error. |
verifyCallback
static
static int verifyCallback(bool server, int ok, X509_STORE_CTX * pStore)The return value of this method defines how errors in verification are handled. Return 0 to terminate the handshake, or 1 to continue despite the error.
