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