qb
2.0.0.0
C++17 Actor Framework
|
Components for secure, encrypted TCP communication (requires OpenSSL). More...
Files | |
file | listener.h |
Implementation of a secure SSL/TLS listener for the QB IO library. | |
file | socket.h |
Implementation of SSL/TLS sockets for secure TCP communication in the QB IO library. | |
file | saccept.h |
Secure (SSL/TLS) TCP connection acceptance transport for the QB IO library. | |
file | stcp.h |
Secure TCP (SSL/TLS) stream transport for the QB IO library. |
Classes | |
class | qb::io::tcp::ssl::listener |
Class implementing a secure SSL/TLS TCP listener for accepting encrypted connections. More... | |
struct | qb::io::ssl::Certificate |
Structure to hold essential SSL certificate information. More... | |
struct | qb::io::ssl::Session |
Opaque wrapper for an OpenSSL SSL_SESSION object. More... | |
class | qb::io::tcp::ssl::socket |
Class implementing secure SSL/TLS TCP socket functionality. More... |
Functions | |
Certificate | qb::io::ssl::get_certificate (SSL *ssl) |
Extract certificate information from an active SSL connection. | |
SSL_CTX * | qb::io::ssl::create_client_context (const SSL_METHOD *method) |
Create an SSL context (SSL_CTX) configured for client-side SSL/TLS operations. | |
SSL_CTX * | qb::io::ssl::create_server_context (const SSL_METHOD *method, std::filesystem::path cert_path, std::filesystem::path key_path) |
Create an SSL context (SSL_CTX) configured for server-side SSL/TLS operations. | |
bool | qb::io::ssl::load_ca_certificates (SSL_CTX *ctx, const std::string &ca_file_path) |
Load CA certificates from a file for peer verification. | |
bool | qb::io::ssl::load_ca_directory (SSL_CTX *ctx, const std::string &ca_dir_path) |
Load CA certificates from a directory for peer verification. | |
bool | qb::io::ssl::set_cipher_list (SSL_CTX *ctx, const std::string &ciphers) |
Set the preferred cipher suites for TLS 1.2 and earlier. | |
bool | qb::io::ssl::set_ciphersuites_tls13 (SSL_CTX *ctx, const std::string &ciphersuites) |
Set the preferred cipher suites for TLS 1.3. | |
bool | qb::io::ssl::set_tls_protocol_versions (SSL_CTX *ctx, int min_version, int max_version) |
Set the minimum and maximum TLS protocol versions. | |
bool | qb::io::ssl::configure_mtls_server_context (SSL_CTX *ctx, const std::string &client_ca_file_path, int verification_mode=SSL_VERIFY_PEER) |
Configure client certificate authentication (mTLS) for a server SSL_CTX. | |
bool | qb::io::ssl::configure_client_certificate (SSL_CTX *ctx, const std::string &client_cert_path, const std::string &client_key_path) |
Configure a client SSL_CTX to use a specific client certificate and private key. | |
bool | qb::io::ssl::set_alpn_protos_client (SSL_CTX *ctx, const std::vector< std::string > &protocols) |
Set the ALPN protocols for a client SSL_CTX to offer during handshake. | |
bool | qb::io::ssl::set_alpn_selection_callback_server (SSL_CTX *ctx, SSL_CTX_alpn_select_cb_func callback, void *arg) |
Set the ALPN selection callback for a server SSL_CTX. | |
bool | qb::io::ssl::enable_server_session_caching (SSL_CTX *ctx, long cache_size) |
Enable and configure server-side SSL session caching. | |
bool | qb::io::ssl::disable_client_session_cache (SSL_CTX *ctx) |
Disable client-side SSL session caching for an SSL_CTX. | |
bool | qb::io::ssl::set_custom_verify_callback (SSL_CTX *ctx, int(*callback)(int, X509_STORE_CTX *), int verification_mode) |
Set a custom callback for X.509 certificate verification. | |
bool | qb::io::ssl::set_ocsp_stapling_client_callback (SSL_CTX *ctx, int(*callback)(SSL *s, void *arg), void *arg) |
Set a callback for the client to handle stapled OCSP responses from the server. | |
bool | qb::io::ssl::set_ocsp_stapling_responder_server (SSL_CTX *ctx, int(*callback)(SSL *s, void *arg), void *arg) |
Set a callback for the server to provide an OCSP response to be stapled. | |
bool | qb::io::ssl::set_sni_hostname_selection_callback_server (SSL_CTX *ctx, int(*callback)(SSL *s, int *al, void *arg), void *arg) |
Set a callback for server-side SNI (Server Name Indication) handling. | |
bool | qb::io::ssl::set_keylog_callback (SSL_CTX *ctx, SSL_CTX_keylog_cb_func callback) |
Set the SSL/TLS key log callback function. | |
bool | qb::io::ssl::configure_dh_parameters_server (SSL_CTX *ctx, const std::string &dh_param_file_path) |
Configure Diffie-Hellman parameters for a server SSL_CTX. | |
bool | qb::io::ssl::configure_ecdh_curves_server (SSL_CTX *ctx, const std::string &curve_names_list) |
Configure preferred ECDH curves for a server SSL_CTX. | |
void | qb::io::ssl::free_session (Session &session) |
Frees an SSL_SESSION object held by qb::io::ssl::Session. | |
bool | qb::io::ssl::enable_post_handshake_auth_server (SSL_CTX *ctx) |
Enable server-side support for TLS 1.3 Post-Handshake Authentication (PHA). |
Components for secure, encrypted TCP communication (requires OpenSSL).
Includes `qb::io::tcp::ssl::socket` and `qb::io::tcp::ssl::listener`.
Certificate qb::io::ssl::get_certificate | ( | SSL * | ssl | ) |
Extract certificate information from an active SSL connection.
ssl | Pointer to the SSL connection structure (SSL*) from which to extract certificate details. |
SSL_CTX * qb::io::ssl::create_client_context | ( | const SSL_METHOD * | method | ) |
Create an SSL context (SSL_CTX) configured for client-side SSL/TLS operations.
method | The SSL/TLS method to use (e.g., TLS_client_method(), SSLv23_client_method()). |
SSL_CTX * qb::io::ssl::create_server_context | ( | const SSL_METHOD * | method, |
std::filesystem::path | cert_path, | ||
std::filesystem::path | key_path ) |
Create an SSL context (SSL_CTX) configured for server-side SSL/TLS operations.
method | The SSL/TLS method to use (e.g., TLS_server_method(), SSLv23_server_method()). |
cert_path | Path to the server's PEM-encoded certificate file. |
key_path | Path to the server's PEM-encoded private key file. |
bool qb::io::ssl::load_ca_certificates | ( | SSL_CTX * | ctx, |
const std::string & | ca_file_path ) |
Load CA certificates from a file for peer verification.
ctx | The SSL_CTX to configure. |
ca_file_path | Path to the PEM-encoded CA certificate file. |
bool qb::io::ssl::load_ca_directory | ( | SSL_CTX * | ctx, |
const std::string & | ca_dir_path ) |
Load CA certificates from a directory for peer verification.
ctx | The SSL_CTX to configure. |
ca_dir_path | Path to the directory containing PEM-encoded CA certificates. The directory must be prepared with c_rehash or equivalent. |
bool qb::io::ssl::set_cipher_list | ( | SSL_CTX * | ctx, |
const std::string & | ciphers ) |
Set the preferred cipher suites for TLS 1.2 and earlier.
ctx | The SSL_CTX to configure. |
ciphers | A string in OpenSSL cipher list format (e.g., "HIGH:!aNULL:!MD5"). |
bool qb::io::ssl::set_ciphersuites_tls13 | ( | SSL_CTX * | ctx, |
const std::string & | ciphersuites ) |
Set the preferred cipher suites for TLS 1.3.
ctx | The SSL_CTX to configure. |
ciphersuites | A string in OpenSSL TLS 1.3 ciphersuite format (e.g., "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"). |
bool qb::io::ssl::set_tls_protocol_versions | ( | SSL_CTX * | ctx, |
int | min_version, | ||
int | max_version ) |
Set the minimum and maximum TLS protocol versions.
ctx | The SSL_CTX to configure. |
min_version | The minimum protocol version (e.g., TLS1_2_VERSION). Use 0 for default. |
max_version | The maximum protocol version (e.g., TLS1_3_VERSION). Use 0 for default. |
bool qb::io::ssl::configure_mtls_server_context | ( | SSL_CTX * | ctx, |
const std::string & | client_ca_file_path, | ||
int | verification_mode = SSL_VERIFY_PEER ) |
Configure client certificate authentication (mTLS) for a server SSL_CTX.
ctx | The server SSL_CTX to configure. |
client_ca_file_path | Path to the PEM-encoded CA certificate file for verifying client certificates. If empty, system default CAs might be used, or no specific client CA is set. |
verification_mode | The verification mode (e.g., SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT). Defaults to SSL_VERIFY_PEER. |
bool qb::io::ssl::configure_client_certificate | ( | SSL_CTX * | ctx, |
const std::string & | client_cert_path, | ||
const std::string & | client_key_path ) |
Configure a client SSL_CTX to use a specific client certificate and private key.
ctx | The client SSL_CTX to configure. |
client_cert_path | Path to the PEM-encoded client certificate file. |
client_key_path | Path to the PEM-encoded client private key file. |
bool qb::io::ssl::set_alpn_protos_client | ( | SSL_CTX * | ctx, |
const std::vector< std::string > & | protocols ) |
Set the ALPN protocols for a client SSL_CTX to offer during handshake.
ctx | The client SSL_CTX to configure. |
protocols | A vector of protocol strings (e.g., {"h2", "http/1.1"}). |
bool qb::io::ssl::set_alpn_selection_callback_server | ( | SSL_CTX * | ctx, |
SSL_CTX_alpn_select_cb_func | callback, | ||
void * | arg ) |
Set the ALPN selection callback for a server SSL_CTX.
ctx | The server SSL_CTX to configure. |
callback | The OpenSSL ALPN selection callback function. |
arg | User-defined argument to be passed to the callback. |
bool qb::io::ssl::enable_server_session_caching | ( | SSL_CTX * | ctx, |
long | cache_size ) |
Enable and configure server-side SSL session caching.
ctx | The server SSL_CTX to configure. |
cache_size | The maximum number of sessions to store in the cache. OpenSSL's default is SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. A size of 0 means unlimited (not recommended). |
bool qb::io::ssl::disable_client_session_cache | ( | SSL_CTX * | ctx | ) |
Disable client-side SSL session caching for an SSL_CTX.
ctx | The client SSL_CTX to configure. |
bool qb::io::ssl::set_custom_verify_callback | ( | SSL_CTX * | ctx, |
int(* | callback )(int, X509_STORE_CTX *), | ||
int | verification_mode ) |
Set a custom callback for X.509 certificate verification.
ctx | The SSL_CTX to configure. |
callback | A user-defined callback function. The callback signature is int callback(int preverify_ok, X509_STORE_CTX *x509_ctx). It should return 1 for success, 0 for failure. |
verification_mode | The verification mode to set (e.g., SSL_VERIFY_PEER). This is passed to SSL_CTX_set_verify along with the callback. |
bool qb::io::ssl::set_ocsp_stapling_client_callback | ( | SSL_CTX * | ctx, |
int(* | callback )(SSL *s, void *arg), | ||
void * | arg ) |
Set a callback for the client to handle stapled OCSP responses from the server.
ctx | The client SSL_CTX to configure. |
callback | The callback function of type int (*cb)(SSL *, void *). Inside this callback, the user can retrieve the OCSP response using SSL_get_tlsext_status_ocsp_resp(). |
arg | User-defined argument to be passed to the callback. |
bool qb::io::ssl::set_ocsp_stapling_responder_server | ( | SSL_CTX * | ctx, |
int(* | callback )(SSL *s, void *arg), | ||
void * | arg ) |
Set a callback for the server to provide an OCSP response to be stapled.
ctx | The server SSL_CTX to configure. |
callback | The callback function of type int (*cb)(SSL *, void *). This callback is responsible for setting the OCSP response using SSL_set_tlsext_status_ocsp_resp(). |
arg | User-defined argument to be passed to the callback. |
bool qb::io::ssl::set_sni_hostname_selection_callback_server | ( | SSL_CTX * | ctx, |
int(* | callback )(SSL *s, int *al, void *arg), | ||
void * | arg ) |
Set a callback for server-side SNI (Server Name Indication) handling.
ctx | The server SSL_CTX on which to set the callback. This context is used if the callback doesn't switch to another one. |
callback | The callback function int (*cb)(SSL *s, int *al, void *arg). This callback can inspect the server name and potentially switch to a different SSL_CTX. It should return SSL_TLSEXT_ERR_OK on success. |
arg | User-defined argument to be passed to the callback. |
bool qb::io::ssl::set_keylog_callback | ( | SSL_CTX * | ctx, |
SSL_CTX_keylog_cb_func | callback ) |
Set the SSL/TLS key log callback function.
ctx | The SSL_CTX to configure. |
callback | The keylog callback function void (*cb)(const SSL *ssl, const char *line). This function will be called with lines of text representing key material. |
bool qb::io::ssl::configure_dh_parameters_server | ( | SSL_CTX * | ctx, |
const std::string & | dh_param_file_path ) |
Configure Diffie-Hellman parameters for a server SSL_CTX.
ctx | The server SSL_CTX to configure. |
dh_param_file_path | Path to a PEM-encoded DH parameters file. |
bool qb::io::ssl::configure_ecdh_curves_server | ( | SSL_CTX * | ctx, |
const std::string & | curve_names_list ) |
Configure preferred ECDH curves for a server SSL_CTX.
ctx | The server SSL_CTX to configure. |
curve_names_list | A colon-separated list of curve NIDs or names (e.g., "P-256:X25519:P-384"). If empty, OpenSSL's default list may be used or auto-selection enabled if supported. |
void qb::io::ssl::free_session | ( | Session & | session | ) |
Frees an SSL_SESSION object held by qb::io::ssl::Session.
session | The qb::io::ssl::Session object to free. The internal handle will be nullified. |
bool qb::io::ssl::enable_post_handshake_auth_server | ( | SSL_CTX * | ctx | ) |
Enable server-side support for TLS 1.3 Post-Handshake Authentication (PHA).
ctx | The server SSL_CTX to configure. |