7 SSL_SESSION_free - create, free and manage SSL_SESSION structures
11 #include <openssl/ssl.h>
13 SSL_SESSION *SSL_SESSION_new(void);
14 int SSL_SESSION_up_ref(SSL_SESSION *ses);
15 void SSL_SESSION_free(SSL_SESSION *session);
19 SSL_SESSION_new() creates a new SSL_SESSION structure and returns a pointer to
22 SSL_SESSION_up_ref() increments the reference count on the given SSL_SESSION
25 SSL_SESSION_free() decrements the reference count of B<session> and removes
26 the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated
27 memory, if the reference count has reached 0.
28 If B<session> is NULL nothing is done.
32 SSL_SESSION objects are allocated, when a TLS/SSL handshake operation
33 is successfully completed. Depending on the settings, see
34 L<SSL_CTX_set_session_cache_mode(3)>,
35 the SSL_SESSION objects are internally referenced by the SSL_CTX and
36 linked into its session cache. SSL objects may be using the SSL_SESSION object;
37 as a session may be reused, several SSL objects may be using one SSL_SESSION
38 object at the same time. It is therefore crucial to keep the reference
39 count (usage information) correct and not delete a SSL_SESSION object
40 that is still used, as this may lead to program failures due to
41 dangling pointers. These failures may also appear delayed, e.g.
42 when an SSL_SESSION object was completely freed as the reference count
43 incorrectly became 0, but it is still referenced in the internal
44 session cache and the cache list is processed during a
45 L<SSL_CTX_flush_sessions(3)> operation.
47 SSL_SESSION_free() must only be called for SSL_SESSION objects, for
48 which the reference count was explicitly incremented (e.g.
49 by calling SSL_get1_session(), see L<SSL_get_session(3)>)
50 or when the SSL_SESSION object was generated outside a TLS handshake
51 operation, e.g. by using L<d2i_SSL_SESSION(3)>.
52 It must not be called on other SSL_SESSION objects, as this would cause
53 incorrect reference counts and therefore program failures.
57 SSL_SESSION_new returns a pointer to the newly allocated SSL_SESSION structure
60 SSL_SESSION_up_ref returns 1 on success or 0 on error.
64 L<ssl(7)>, L<SSL_get_session(3)>,
65 L<SSL_CTX_set_session_cache_mode(3)>,
66 L<SSL_CTX_flush_sessions(3)>,
71 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
73 Licensed under the OpenSSL license (the "License"). You may not use
74 this file except in compliance with the License. You can obtain a copy
75 in the file LICENSE in the source distribution or at
76 L<https://www.openssl.org/source/license.html>.