SSL_NEW(3ossl)
π SSL_NEW(3ossl) β or: how to birth a whole SSL structure π
okay so bestie, this is the OpenSSL page for SSL_dup, SSL_new and SSL_up_ref, and it's literally the "how do I make an SSL object" page. it's giving creation myth, but make it TLS. β¨
β¨ NAME β¨
SSL_dup, SSL_new, SSL_up_ref β create an SSL structure for a connection π¦
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
SSL *SSL_dup(SSL *s);
SSL *SSL_new(SSL_CTX *ctx);
int SSL_up_ref(SSL *s);
π DESCRIPTION π
So SSL_new() creates a brand-new SSL structure, and that's the little guy you need to hold 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, and the things it picks up are: connection method, options, verification settings, timeout settings. an SSL structure is reference counted β the way that works is, creating an SSL structure for the first time increments the reference count, and freeing it (using SSL_free) decrements it. when the reference count drops to zero, any memory or resources allocated to the SSL structure are freed. slay, that's the whole lifecycle. π
SSL_up_ref() increments the reference count for an existing SSL structure. that's it. that's the whole function. iconic.
Then there's SSL_dup() β it 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.
β οΈ okay this part is important, don't skip it: forSSL_dup()to work, the connection MUST be in its initial state and MUST NOT have yet started the SSL handshake. for connections that are not in their initial state,SSL_dup()just increments an internal reference count and returns the same handle. π
It may be possible to use SSL_clear(3) to recycle an SSL handle that is not in its initial state for reuse, but this is best avoided. instead: save and restore the session, if desired, and construct a fresh handle for each connection. like, fresh handle per connection is the vibe, fr fr. π§
π«Ά 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
ok and one more thing: SSL_dup() is not supported on QUIC SSL objects and returns NULL if called on such an object. no QUIC dup for you, bestie. π
π 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.
also, SSL_up_ref() returns 1 for success and 0 for failure. tiny numbers, big meaning. β
π₯ SEE ALSO π₯
SSL_free(3), SSL_clear(3), SSL_CTX_set_options(3), SSL_get_SSL_CTX(3), ssl(7)
go read those too, iykyk. π
π 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 SSL_new() responsibly. π
mwah π β this was SSL_NEW(3ossl) from OpenSSL, version 3.5.0, dated 2026-09-25, page name SSL_NEW(3ossl). you're welcome, ily, bye! ππ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms