SSL_CTX_NEW(3)
π¦ SSL_CTX_new(3): the TLS framework page π¦
okay so you're looking at SSL_CTX_NEW(3) from the Library Functions Manual, bestie. Buckle up: this is the page that hands you a whole SSL_CTX object, aka the framework for TLS enabled functions. It's giving foundational. π
πΈ NAME πΈ
SSL_CTX_new, SSL_CTX_up_ref, TLS_method, TLS_server_method, TLS_client_method, SSLv23_method, SSLv23_server_method, SSLv23_client_method, TLSv1_method, TLSv1_server_method, TLSv1_client_method, TLSv1_1_method, TLSv1_1_server_method, TLSv1_1_client_method, TLSv1_2_method, TLSv1_2_server_method, TLSv1_2_client_method, DTLS_method, DTLS_server_method, DTLS_client_method, DTLSv1_method, DTLSv1_server_method, DTLSv1_client_method, DTLSv1_2_method, DTLSv1_2_server_method, DTLSv1_2_client_method β create a new SSL_CTX object as a framework for TLS enabled functions.
β¨ SYNOPSIS β¨
library line and include, exactly:
library βlibsslβ libcrypto #include <openssl/ssl.h>
then the signatures, all iconic, none skipped:
SSL_CTX *
SSL_CTX_new(const SSL_METHOD *method);
int
SSL_CTX_up_ref(SSL_CTX *ctx);
const SSL_METHOD *
TLS_method(void);
const SSL_METHOD *
TLS_server_method(void);
const SSL_METHOD *
TLS_client_method(void);
const SSL_METHOD *
SSLv23_method(void);
const SSL_METHOD *
SSLv23_server_method(void);
const SSL_METHOD *
SSLv23_client_method(void);
const SSL_METHOD *
TLSv1_method(void);
const SSL_METHOD *
TLSv1_server_method(void);
const SSL_METHOD *
TLSv1_client_method(void);
const SSL_METHOD *
TLSv1_1_method(void);
const SSL_METHOD *
TLSv1_1_server_method(void);
const SSL_METHOD *
TLSv1_1_client_method(void);
const SSL_METHOD *
TLSv1_2_method(void);
const SSL_METHOD *
TLSv1_2_server_method(void);
const SSL_METHOD *
TLSv1_2_client_method(void);
const SSL_METHOD *
DTLS_method(void);
const SSL_METHOD *
DTLS_server_method(void);
const SSL_METHOD *
DTLS_client_method(void);
const SSL_METHOD *
DTLSv1_method(void);
const SSL_METHOD *
DTLSv1_server_method(void);
const SSL_METHOD *
DTLSv1_client_method(void);
const SSL_METHOD *
DTLSv1_2_method(void);
const SSL_METHOD *
DTLSv1_2_server_method(void);
const SSL_METHOD *
DTLSv1_2_client_method(void);
π DESCRIPTION π
SSL_CTX_new() creates a brand-new SSL_CTX object β your framework for establishing TLS or DTLS enabled connections. It initializes the list of ciphers, the session cache setting, the callbacks, the keys and certificates, the options, and the security level to its default values. Basically it's the starter pack, already configured. π
An SSL_CTX object is reference counted, no cap. Creating a new SSL_CTX object sets its reference count to 1. Calling SSL_CTX_up_ref() on it increments the reference count by 1. Calling SSL_CTX_free(3) on it decrements the reference count by 1. When the reference count drops to zero, any memory or resources allocated to the SSL_CTX object are freed. Periodt.
The SSL_CTX object uses method as its connection method. The main-character choices are:
TLS_method()β the general-purpose version-flexible TLS method. The protocol version used will be negotiated to the highest version mutually supported by the client and the server. The supported protocols areTLSv1,TLSv1.1,TLSv1.2, andTLSv1.3.DTLS_method()β the version-flexible DTLS method. The currently supported protocols areDTLSv1andDTLSv1.2.
The following method arguments are deprecated β yes, the whole list. Heads up:
TLS_server_method(),TLS_client_method(),SSLv23_method(),SSLv23_server_method(),SSLv23_client_method()β deprecated aliases forTLS_method().DTLS_server_method(),DTLS_client_method()β deprecated aliases forDTLS_method().TLSv1_method(),TLSv1_server_method(),TLSv1_client_method()β a connection established with these methods will only understand theTLSv1protocol.TLSv1_1_method(),TLSv1_1_server_method(),TLSv1_1_client_method()β a connection established with these methods will only understand theTLSv1.1protocol.TLSv1_2_method(),TLSv1_2_server_method(),TLSv1_2_client_method()β a connection established with these methods will only understand theTLSv1.2protocol.DTLSv1_method(),DTLSv1_server_method(),DTLSv1_client_method()β these are the version-specific methods forDTLSv1.DTLSv1_2_method(),DTLSv1_2_server_method(),DTLSv1_2_client_method()β these are the version-specific methods forDTLSv1.2.
In LibreSSL, the methods containing the substrings _server or _client in their names return the same objects as the methods without these substrings. iykyk.
The list of protocols available can also be limited using the SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1, and SSL_OP_NO_TLSv1_2 options of the SSL_CTX_set_options(3) or SSL_set_options(3) functions, but this approach is not recommended. Clients should avoid creating "holes" in the set of protocols they support. When disabling a protocol, make sure that you also disable either all previous or all subsequent protocol versions. In clients, when a protocol version is disabled without disabling all previous protocol versions, the effect is to also disable all subsequent protocol versions. That's the plot twist. π
DTLSv1 and DTLSv1.2 can be disabled with SSL_CTX_set_options(3) or SSL_set_options(3) using the SSL_OP_NO_DTLSv1 and SSL_OP_NO_DTLSv1_2 options, respectively.
π RETURN VALUES π
SSL_CTX_new()β returns a pointer to the newly allocated object orNULLon failure. Check the error stack to find out the reason for failure.SSL_CTX_up_ref()β returns1for success or0for failure.TLS_method()and the other*_method()functions β return pointers to constant static objects.
π SEE ALSO π
ssl(3)SSL_accept(3)SSL_CTX_free(3)SSL_CTX_set_min_proto_version(3)SSL_CTX_set_options(3)SSL_CTX_set_security_level(3)SSL_set_connect_state(3)
π§ HISTORY π§
SSL_CTX_new() first appeared in SSLeay 0.5.1. SSLv23_method(), SSLv23_server_method(), and SSLv23_client_method() first appeared in SSLeay 0.8.0. TLSv1_method(), TLSv1_server_method(), and TLSv1_client_method() first appeared in SSLeay 0.9.0. All these functions have been available since OpenBSD 2.4.
DTLSv1_method(),DTLSv1_server_method(), andDTLSv1_client_method()first appeared in OpenSSL 0.9.8 and have been available since OpenBSD 4.5.TLSv1_1_method(),TLSv1_1_server_method(),TLSv1_1_client_method(),TLSv1_2_method(),TLSv1_2_server_method(), andTLSv1_2_client_method()first appeared in OpenSSL 1.0.1 and have been available since OpenBSD 5.3.DTLS_method(),DTLS_server_method(), andDTLS_client_method()first appeared in OpenSSL 1.0.2 and have been available since OpenBSD 6.5.TLS_method(),TLS_server_method(), andTLS_client_method()first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 5.8.SSL_CTX_up_ref()first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3.DTLSv1_2_method(),DTLSv1_2_server_method(), andDTLSv1_2_client_method()first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.9.
xoxo, this page is from the Debian source/version, dated June 8, 2025, and that's the whole SSL_CTX_NEW(3) vibe. πβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2005, 2012, 2013, 2015, 2016 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms