1 .\" $OpenBSD: SSL_SESSION_free.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $
2 .\" full merge up to: OpenSSL b31db505 Mar 24 16:01:50 2017 +0000
4 .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>
5 .\" and Matt Caswell <matt@openssl.org>.
6 .\" Copyright (c) 2000, 2001, 2009, 2017 The OpenSSL Project.
7 .\" All rights reserved.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
16 .\" 2. Redistributions in binary form must reproduce the above copyright
17 .\" notice, this list of conditions and the following disclaimer in
18 .\" the documentation and/or other materials provided with the
21 .\" 3. All advertising materials mentioning features or use of this
22 .\" software must display the following acknowledgment:
23 .\" "This product includes software developed by the OpenSSL Project
24 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 .\" endorse or promote products derived from this software without
28 .\" prior written permission. For written permission, please contact
29 .\" openssl-core@openssl.org.
31 .\" 5. Products derived from this software may not be called "OpenSSL"
32 .\" nor may "OpenSSL" appear in their names without prior written
33 .\" permission of the OpenSSL Project.
35 .\" 6. Redistributions of any form whatsoever must retain the following
37 .\" "This product includes software developed by the OpenSSL Project
38 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
53 .Dd $Mdocdate: March 27 2018 $
54 .Dt SSL_SESSION_FREE 3
57 .Nm SSL_SESSION_up_ref ,
59 .Nd SSL_SESSION reference counting
63 .Fn SSL_SESSION_up_ref "SSL_SESSION *session"
65 .Fn SSL_SESSION_free "SSL_SESSION *session"
67 .Fn SSL_SESSION_up_ref
68 increments the reference count of the given
73 decrements the reference count of the given
76 If the reference count reaches 0, it frees the memory used by the
82 pointer, no action occurs.
85 objects are allocated when a TLS/SSL handshake operation is successfully
87 Depending on the settings, see
88 .Xr SSL_CTX_set_session_cache_mode 3 ,
91 objects are internally referenced by the
93 and linked into its session cache.
95 objects may be using the
97 object; as a session may be reused, several
99 objects may be using one
101 object at the same time.
102 It is therefore crucial to keep the reference count (usage information) correct
105 object that is still used, as this may lead to program failures due to dangling
107 These failures may also appear delayed, e.g., when an
109 object is completely freed as the reference count incorrectly becomes 0, but it
110 is still referenced in the internal session cache and the cache list is
112 .Xr SSL_CTX_flush_sessions 3
116 must only be called for
118 objects, for which the reference count was explicitly incremented (e.g., by
120 .Xr SSL_get1_session 3 ;
122 .Xr SSL_get_session 3 )
125 object was generated outside a TLS handshake operation, e.g., by using
126 .Xr d2i_SSL_SESSION 3 .
127 It must not be called on other
129 objects, as this would cause incorrect reference counts and therefore program
132 .Fn SSL_SESSION_up_ref
133 returns 1 on success or 0 on error.
135 .Xr d2i_SSL_SESSION 3 ,
136 .Xr SSL_CTX_flush_sessions 3 ,
137 .Xr SSL_CTX_set_session_cache_mode 3 ,
138 .Xr SSL_get_session 3 ,
139 .Xr SSL_SESSION_new 3
142 first appeared in SSLeay 0.5.2 and has been available since
145 .Fn SSL_SESSION_up_ref
146 first appeared in OpenSSL 1.1.0 and has been available since