1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos SSL_SESSION_new, 6 1.1 christos SSL_SESSION_dup, 7 1.1 christos SSL_SESSION_up_ref, 8 1.1 christos SSL_SESSION_free - create, free and manage SSL_SESSION structures 9 1.1 christos 10 1.1 christos =head1 SYNOPSIS 11 1.1 christos 12 1.1 christos #include <openssl/ssl.h> 13 1.1 christos 14 1.1 christos SSL_SESSION *SSL_SESSION_new(void); 15 1.1 christos SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src); 16 1.1 christos int SSL_SESSION_up_ref(SSL_SESSION *ses); 17 1.1 christos void SSL_SESSION_free(SSL_SESSION *session); 18 1.1 christos 19 1.1 christos =head1 DESCRIPTION 20 1.1 christos 21 1.1 christos SSL_SESSION_new() creates a new SSL_SESSION structure and returns a pointer to 22 1.1 christos it. 23 1.1 christos 24 1.1 christos SSL_SESSION_dup() creates a new SSL_SESSION structure that is a copy of B<src>. 25 1.1 christos The copy is not owned by any cache that B<src> may have been in. 26 1.1 christos 27 1.1 christos SSL_SESSION_up_ref() increments the reference count on the given SSL_SESSION 28 1.1 christos structure. 29 1.1 christos 30 1.1 christos SSL_SESSION_free() decrements the reference count of B<session> and removes 31 1.1 christos the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated 32 1.1 christos memory, if the reference count has reached 0. 33 1.1 christos If B<session> is NULL nothing is done. 34 1.1 christos 35 1.1 christos =head1 NOTES 36 1.1 christos 37 1.1 christos SSL_SESSION objects are allocated, when a TLS/SSL handshake operation 38 1.1 christos is successfully completed. Depending on the settings, see 39 1.1 christos L<SSL_CTX_set_session_cache_mode(3)>, 40 1.1 christos the SSL_SESSION objects are internally referenced by the SSL_CTX and 41 1.1 christos linked into its session cache. SSL objects may be using the SSL_SESSION object; 42 1.1 christos as a session may be reused, several SSL objects may be using one SSL_SESSION 43 1.1 christos object at the same time. It is therefore crucial to keep the reference 44 1.1 christos count (usage information) correct and not delete an SSL_SESSION object 45 1.1 christos that is still used, as this may lead to program failures due to 46 1.1 christos dangling pointers. These failures may also appear delayed, e.g. 47 1.1 christos when an SSL_SESSION object was completely freed as the reference count 48 1.1 christos incorrectly became 0, but it is still referenced in the internal 49 1.1 christos session cache and the cache list is processed during a 50 1.1 christos L<SSL_CTX_flush_sessions(3)> operation. 51 1.1 christos 52 1.1 christos SSL_SESSION_free() must only be called for SSL_SESSION objects, for 53 1.1 christos which the reference count was explicitly incremented (e.g. 54 1.1 christos by calling SSL_get1_session(), see L<SSL_get_session(3)>) 55 1.1 christos or when the SSL_SESSION object was generated outside a TLS handshake 56 1.1 christos operation, e.g. by using L<d2i_SSL_SESSION(3)>. 57 1.1 christos It must not be called on other SSL_SESSION objects, as this would cause 58 1.1 christos incorrect reference counts and therefore program failures. 59 1.1 christos 60 1.1 christos =head1 RETURN VALUES 61 1.1 christos 62 1.1 christos SSL_SESSION_new returns a pointer to the newly allocated SSL_SESSION structure 63 1.1 christos or NULL on error. 64 1.1 christos 65 1.1 christos SSL_SESSION_dup returns a pointer to the new copy or NULL on error. 66 1.1 christos 67 1.1 christos SSL_SESSION_up_ref returns 1 on success or 0 on error. 68 1.1 christos 69 1.1 christos =head1 SEE ALSO 70 1.1 christos 71 1.1 christos L<ssl(7)>, L<SSL_get_session(3)>, 72 1.1 christos L<SSL_CTX_set_session_cache_mode(3)>, 73 1.1 christos L<SSL_CTX_flush_sessions(3)>, 74 1.1 christos L<d2i_SSL_SESSION(3)> 75 1.1 christos 76 1.1 christos =head1 HISTORY 77 1.1 christos 78 1.1 christos The SSL_SESSION_dup() function was added in OpenSSL 1.1.1. 79 1.1 christos 80 1.1 christos =head1 COPYRIGHT 81 1.1 christos 82 1.1 christos Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved. 83 1.1 christos 84 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 85 1.1 christos this file except in compliance with the License. You can obtain a copy 86 1.1 christos in the file LICENSE in the source distribution or at 87 1.1 christos L<https://www.openssl.org/source/license.html>. 88 1.1 christos 89 1.1 christos =cut 90