Net module

SSLManager

[Singleton]({#ref classicy_1_1Singleton #}) that owns the default client/server TLS contexts and related callbacks.

SSLManager

#include <icy/net/sslmanager.h>

Singleton that owns the default client/server TLS contexts and related callbacks.

Public Attributes

ReturnNameDescription
ThreadSignal< void(VerificationErrorDetails &)>ServerVerificationErrorFired whenever a certificate verification error is detected by the server during a handshake.
ThreadSignal< void(VerificationErrorDetails &)>ClientVerificationErrorFired whenever a certificate verification error is detected by the client during a handshake.
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.

ServerVerificationError

ThreadSignal< void(VerificationErrorDetails &)> ServerVerificationError

Fired whenever a certificate verification error is detected by the server during a handshake.


ClientVerificationError

ThreadSignal< void(VerificationErrorDetails &)> ClientVerificationError

Fired whenever a certificate verification error is detected by the client during a handshake.


PrivateKeyPassphraseRequired

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.

Public Methods

ReturnNameDescription
voidinitializeServerInitializes the server side of the SSLManager server-side SSLContext.
voidinitializeClientInitializes the client side of the SSLManager with a default client-side SSLContext.
SSLContext::PtrdefaultServerContextReturns the default context used by the server if initialized.
SSLContext::PtrdefaultClientContextReturns the default context used by the client if initialized.
voidshutdownShuts 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

ReturnNameDescription
SSLManager &instance staticReturns the instance of the SSLManager singleton.
voiddestroy staticShuts down and destroys the SSLManager singleton instance.
voidinitNoVerifyClient staticInitializes a default no-verify client context that's useful for testing.
voidinitNoVerifyServer staticInitializes 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

ReturnNameDescription
SSLContext::Ptr_defaultServerContext
SSLContext::Ptr_defaultClientContext
std::mutex_mutex

_defaultServerContext

SSLContext::Ptr _defaultServerContext

_defaultClientContext

SSLContext::Ptr _defaultClientContext

_mutex

std::mutex _mutex

Private Methods

ReturnNameDescription
SSLManagerCreates the SSLManager.
~SSLManagerDestroys the SSLManager.
SSLManagerDeleted constructor.
SSLManagerDeleted constructor.

SSLManager

SSLManager()

Creates the SSLManager.


~SSLManager

~SSLManager() noexcept

Destroys the SSLManager.


SSLManager

SSLManager(const SSLManager &) = delete

Deleted constructor.


SSLManager

SSLManager(SSLManager &&) = delete

Deleted constructor.

Private Static Methods

ReturnNameDescription
intverifyCallback staticThe 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.