1*4724848cSchristos=pod 2*4724848cSchristos 3*4724848cSchristos=head1 NAME 4*4724848cSchristos 5*4724848cSchristosSSL_dup, SSL_new, SSL_up_ref - create an SSL structure for a connection 6*4724848cSchristos 7*4724848cSchristos=head1 SYNOPSIS 8*4724848cSchristos 9*4724848cSchristos #include <openssl/ssl.h> 10*4724848cSchristos 11*4724848cSchristos SSL *SSL_dup(SSL *s); 12*4724848cSchristos SSL *SSL_new(SSL_CTX *ctx); 13*4724848cSchristos int SSL_up_ref(SSL *s); 14*4724848cSchristos 15*4724848cSchristos=head1 DESCRIPTION 16*4724848cSchristos 17*4724848cSchristosSSL_new() creates a new B<SSL> structure which is needed to hold the 18*4724848cSchristosdata for a TLS/SSL connection. The new structure inherits the settings 19*4724848cSchristosof the underlying context B<ctx>: connection method, 20*4724848cSchristosoptions, verification settings, timeout settings. An B<SSL> structure is 21*4724848cSchristosreference counted. Creating an B<SSL> structure for the first time increments 22*4724848cSchristosthe reference count. Freeing it (using SSL_free) decrements it. When the 23*4724848cSchristosreference count drops to zero, any memory or resources allocated to the B<SSL> 24*4724848cSchristosstructure are freed. 25*4724848cSchristos 26*4724848cSchristosSSL_up_ref() increments the reference count for an 27*4724848cSchristosexisting B<SSL> structure. 28*4724848cSchristos 29*4724848cSchristosThe function SSL_dup() creates and returns a new B<SSL> structure from the same 30*4724848cSchristosB<SSL_CTX> that was used to create I<s>. It additionally duplicates a subset of 31*4724848cSchristosthe settings in I<s> into the new B<SSL> object. 32*4724848cSchristos 33*4724848cSchristosFor SSL_dup() to work, the connection MUST be in its initial state and 34*4724848cSchristosMUST NOT have yet started the SSL handshake. For connections that are not in 35*4724848cSchristostheir initial state SSL_dup() just increments an internal 36*4724848cSchristosreference count and returns the I<same> handle. It may be possible to 37*4724848cSchristosuse L<SSL_clear(3)> to recycle an SSL handle that is not in its initial 38*4724848cSchristosstate for re-use, but this is best avoided. Instead, save and restore 39*4724848cSchristosthe session, if desired, and construct a fresh handle for each connection. 40*4724848cSchristos 41*4724848cSchristosThe subset of settings in I<s> that are duplicated are: 42*4724848cSchristos 43*4724848cSchristos=over 4 44*4724848cSchristos 45*4724848cSchristos=item any session data if configured (including the session_id_context) 46*4724848cSchristos 47*4724848cSchristos=item any tmp_dh settings set via L<SSL_set_tmp_dh(3)>, 48*4724848cSchristosL<SSL_set_tmp_dh_callback(3)>, or L<SSL_set_dh_auto(3)> 49*4724848cSchristos 50*4724848cSchristos=item any configured certificates, private keys or certificate chains 51*4724848cSchristos 52*4724848cSchristos=item any configured signature algorithms, or client signature algorithms 53*4724848cSchristos 54*4724848cSchristos=item any DANE settings 55*4724848cSchristos 56*4724848cSchristos=item any Options set via L<SSL_set_options(3)> 57*4724848cSchristos 58*4724848cSchristos=item any Mode set via L<SSL_set_mode(3)> 59*4724848cSchristos 60*4724848cSchristos=item any minimum or maximum protocol settings set via 61*4724848cSchristosL<SSL_set_min_proto_version(3)> or L<SSL_set_max_proto_version(3)> (Note: Only 62*4724848cSchristosfrom OpenSSL 1.1.1h and above) 63*4724848cSchristos 64*4724848cSchristos=item any Verify mode, callback or depth set via L<SSL_set_verify(3)> or 65*4724848cSchristosL<SSL_set_verify_depth(3)> or any configured X509 verification parameters 66*4724848cSchristos 67*4724848cSchristos=item any msg callback or info callback set via L<SSL_set_msg_callback(3)> or 68*4724848cSchristosL<SSL_set_info_callback(3)> 69*4724848cSchristos 70*4724848cSchristos=item any default password callback set via L<SSL_set_default_passwd_cb(3)> 71*4724848cSchristos 72*4724848cSchristos=item any session id generation callback set via L<SSL_set_generate_session_id(3)> 73*4724848cSchristos 74*4724848cSchristos=item any configured Cipher List 75*4724848cSchristos 76*4724848cSchristos=item initial accept (server) or connect (client) state 77*4724848cSchristos 78*4724848cSchristos=item the max cert list value set via L<SSL_set_max_cert_list(3)> 79*4724848cSchristos 80*4724848cSchristos=item the read_ahead value set via L<SSL_set_read_ahead(3)> 81*4724848cSchristos 82*4724848cSchristos=item application specific data set via L<SSL_set_ex_data(3)> 83*4724848cSchristos 84*4724848cSchristos=item any CA list or client CA list set via L<SSL_set0_CA_list(3)>, 85*4724848cSchristosSSL_set0_client_CA_list() or similar functions 86*4724848cSchristos 87*4724848cSchristos=item any security level settings or callbacks 88*4724848cSchristos 89*4724848cSchristos=item any configured serverinfo data 90*4724848cSchristos 91*4724848cSchristos=item any configured PSK identity hint 92*4724848cSchristos 93*4724848cSchristos=item any configured custom extensions 94*4724848cSchristos 95*4724848cSchristos=item any client certificate types configured via SSL_set1_client_certificate_types 96*4724848cSchristos 97*4724848cSchristos=back 98*4724848cSchristos 99*4724848cSchristos=head1 RETURN VALUES 100*4724848cSchristos 101*4724848cSchristosThe following return values can occur: 102*4724848cSchristos 103*4724848cSchristos=over 4 104*4724848cSchristos 105*4724848cSchristos=item NULL 106*4724848cSchristos 107*4724848cSchristosThe creation of a new SSL structure failed. Check the error stack to 108*4724848cSchristosfind out the reason. 109*4724848cSchristos 110*4724848cSchristos=item Pointer to an SSL structure 111*4724848cSchristos 112*4724848cSchristosThe return value points to an allocated SSL structure. 113*4724848cSchristos 114*4724848cSchristosSSL_up_ref() returns 1 for success and 0 for failure. 115*4724848cSchristos 116*4724848cSchristos=back 117*4724848cSchristos 118*4724848cSchristos=head1 SEE ALSO 119*4724848cSchristos 120*4724848cSchristosL<SSL_free(3)>, L<SSL_clear(3)>, 121*4724848cSchristosL<SSL_CTX_set_options(3)>, 122*4724848cSchristosL<SSL_get_SSL_CTX(3)>, 123*4724848cSchristosL<ssl(7)> 124*4724848cSchristos 125*4724848cSchristos=head1 COPYRIGHT 126*4724848cSchristos 127*4724848cSchristosCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. 128*4724848cSchristos 129*4724848cSchristosLicensed under the OpenSSL license (the "License"). You may not use 130*4724848cSchristosthis file except in compliance with the License. You can obtain a copy 131*4724848cSchristosin the file LICENSE in the source distribution or at 132*4724848cSchristosL<https://www.openssl.org/source/license.html>. 133*4724848cSchristos 134*4724848cSchristos=cut 135