Fix typo in HKDF example documentation
[openssl.git] / doc / man3 / SSL_SESSION_free.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_SESSION_new,
6 SSL_SESSION_up_ref,
7 SSL_SESSION_free - create, free and manage SSL_SESSION structures
8
9 =head1 SYNOPSIS
10
11  #include <openssl/ssl.h>
12
13  SSL_SESSION *SSL_SESSION_new(void);
14  int SSL_SESSION_up_ref(SSL_SESSION *ses);
15  void SSL_SESSION_free(SSL_SESSION *session);
16
17 =head1 DESCRIPTION
18
19 SSL_SESSION_new() creates a new SSL_SESSION structure and returns a pointer to
20 it.
21
22 SSL_SESSION_up_ref() increments the reference count on the given SSL_SESSION
23 structure.
24
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.
29
30 =head1 NOTES
31
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.
46
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.
54
55 =head1 RETURN VALUES
56
57 SSL_SESSION_new returns a pointer to the newly allocated SSL_SESSION structure
58 or NULL on error.
59
60 SSL_SESSION_up_ref returns 1 on success or 0 on error.
61
62 =head1 SEE ALSO
63
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)>,
67 L<d2i_SSL_SESSION(3)>
68
69 =head1 COPYRIGHT
70
71 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
72
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>.
77
78 =cut