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