Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches

◆ clientSSLContextSelectionCallback

std::function<SSL_CTX*(const std::string& host)> Ice::SSL::OpenSSLClientAuthenticationOptions::clientSSLContextSelectionCallback {}

A callback that selects the client's SSL_CTX object based on the target host name.

This callback associates a specific SSL configuration with an outgoing connection identified by the target host name. The callback must return a pointer to a valid SSL_CTX object previously initialized using the OpenSSL API. The SSL transport takes ownership of the returned SSL_CTX object and releases it after closing the connection.

If the application does not provide a callback, the SSL transport will use an SSL_CTX object created with SSL_CTX_new(), which uses the default OpenSSL configuration.

The SSL transport calls this callback for each new outgoing connection to obtain the SSL_CTX object before starting the SSL handshake.

Parameters
hostThe target host name.
Returns
A pointer to an SSL_CTX object representing the SSL configuration for the new outgoing connection.

Example of setting clientSSLContextSelectionCallback:

SSL_CTX* sslContext = SSL_CTX_new(TLS_method());
// ...
auto initData = Ice::InitializationData{
.clientAuthenticationOptions = Ice::SSL::ClientAuthenticationOptions{
.clientSSLContextSelectionCallback = [sslContext](const std::string&)
{
// Keep the SSLContext alive for the lifetime of the connection.
SSL_CTX_up_ref(sslContext);
return sslContext;
}}};
auto communicator = Ice::initialize(initData);
// ...
// Release ssl context when no longer needed
SSL_CTX_free(sslContext);

Definition at line 219 of file ClientAuthenticationOptions.h.