SSL_NEW(3ossl)
πΈ SSL_NEW(3ossl) β or: how to birth a whole TLS connection π
okay so this is the 3ossl girlies' guide to making SSL objects. yes bestie, the manual page name is literally SSL_NEW(3ossl) and it covers SSL_dup, SSL_new, and SSL_up_ref β the creation trio. let's go π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
SSL *SSL_dup(SSL *s);
SSL *SSL_new(SSL_CTX *ctx);
int SSL_up_ref(SSL *s);
π¦ DESCRIPTION π¦
SSL_new() β the main character π
SSL_new() creates a brand-new SSL structure, and like⦠you need this thing, it's literally what holds all the data for a TLS/SSL connection. no SSL struct, no connection, periodt.
the new structure inherits the settings of the underlying context ctx:
- connection method
- options
- verification settings
- timeout settings
an SSL structure is reference counted, iykyk. creating one for the first time bumps the reference count up by one βοΈ. freeing it (with SSL_free) decrements it π. and the second that reference count hits zero, any memory or resources allocated to the SSL structure get freed. bye bestie, gone, released π«Ά
SSL_up_ref() β the hype girl π
SSL_up_ref() just increments the reference count for an existing SSL structure. that's it. that's the whole job. iconic honestly.
SSL_dup() β the clone saga π§¬
the function SSL_dup() creates and returns a new SSL structure from the same SSL_CTX that was used to create s. it additionally duplicates a subset of the settings in s into the new SSL object.
β οΈ for SSL_dup() to work, the connection MUST be in its initial state and MUST NOT have yet started the SSL handshake. no exceptions, no cap.
for connections that are not in their initial state, SSL_dup() just increments an internal reference count and returns the same handle. like, same object, different day π. it may be possible to use SSL_clear(3) to recycle an SSL handle that isn't in its initial state for reuse, but fr fr this is best avoided. instead: save and restore the session if you want it, and construct a fresh handle for each connection. clean slate energy β¨
the subset of settings in s that get duplicated π
- any session data if configured (including the
session_id_context) - any
tmp_dhsettings set viaSSL_set_tmp_dh(3),SSL_set_tmp_dh_callback(3), orSSL_set_dh_auto(3) - any configured certificates, private keys or certificate chains
- any configured signature algorithms, or client signature algorithms
- any DANE settings
- any Options set via
SSL_set_options(3) - any Mode set via
SSL_set_mode(3) - any minimum or maximum protocol settings set via
SSL_set_min_proto_version(3)orSSL_set_max_proto_version(3)(Note: Only from OpenSSL 1.1.1h and above) - any verify mode, callback or depth set via
SSL_set_verify(3)orSSL_set_verify_depth(3)or any configured X509 verification parameters - any msg callback or info callback set via
SSL_set_msg_callback(3)orSSL_set_info_callback(3) - any default password callback set via
SSL_set_default_passwd_cb(3) - any session id generation callback set via
SSL_set_generate_session_id(3) - any configured Cipher List
- initial accept (server) or connect (client) state
- the max cert list value set via
SSL_set_max_cert_list(3) - the
read_aheadvalue set viaSSL_set_read_ahead(3) - application specific data set via
SSL_set_ex_data(3) - any CA list or client CA list set via
SSL_set0_CA_list(3),SSL_set0_client_CA_list()or similar functions - any security level settings or callbacks
- any configured serverinfo data
- any configured PSK identity hint
- any configured custom extensions
- any client certificate types configured via
SSL_set1_client_certificate_types
π«SSL_dup()is not supported on QUIC SSL objects and returnsNULLif called on such an object. QUIC girlies, this one's not for you π
π RETURN VALUES π
the following return values can occur:
NULLβ the creation of a newSSLstructure failed π. check the error stack to find out the reason.- Pointer to an
SSLstructure β the return value points to an allocatedSSLstructure. slay β¨
and separately: SSL_up_ref() returns 1 for success and 0 for failure.
π₯ SEE ALSO π₯
SSL_free(3), SSL_clear(3), SSL_CTX_set_options(3), SSL_get_SSL_CTX(3), ssl(7)
π COPYRIGHT π
Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay that's the whole page bestie, go forth and make your SSL objects responsibly π§π
~ with love, signed off from the 3ossl corner β OpenSSL 3.5.6, dated 2026-04-07 ~ π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms