]>
Commit | Line | Data |
---|---|---|
cc99526d RL |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
b31db505 MC |
5 | SSL_SESSION_new, |
6 | SSL_SESSION_up_ref, | |
7 | SSL_SESSION_free - create, free and manage SSL_SESSION structures | |
cc99526d RL |
8 | |
9 | =head1 SYNOPSIS | |
10 | ||
11 | #include <openssl/ssl.h> | |
12 | ||
b31db505 MC |
13 | SSL_SESSION *SSL_SESSION_new(void); |
14 | int SSL_SESSION_up_ref(SSL_SESSION *ses); | |
e31e385c | 15 | void SSL_SESSION_free(SSL_SESSION *session); |
cc99526d RL |
16 | |
17 | =head1 DESCRIPTION | |
18 | ||
b31db505 MC |
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 | ||
cc99526d | 25 | SSL_SESSION_free() decrements the reference count of B<session> and removes |
1e4e5492 | 26 | the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated |
477fd459 | 27 | memory, if the reference count has reached 0. |
62adbcee | 28 | If B<session> is NULL nothing is done. |
cc99526d | 29 | |
56fa8e69 LJ |
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 | |
9b86974e | 34 | L<SSL_CTX_set_session_cache_mode(3)>, |
56fa8e69 LJ |
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 | |
9b86974e | 45 | L<SSL_CTX_flush_sessions(3)> operation. |
56fa8e69 LJ |
46 | |
47 | SSL_SESSION_free() must only be called for SSL_SESSION objects, for | |
48 | which the reference count was explicitly incremented (e.g. | |
9b86974e | 49 | by calling SSL_get1_session(), see L<SSL_get_session(3)>) |
56fa8e69 | 50 | or when the SSL_SESSION object was generated outside a TLS handshake |
9b86974e | 51 | operation, e.g. by using L<d2i_SSL_SESSION(3)>. |
56fa8e69 LJ |
52 | It must not be called on other SSL_SESSION objects, as this would cause |
53 | incorrect reference counts and therefore program failures. | |
54 | ||
cc99526d RL |
55 | =head1 RETURN VALUES |
56 | ||
b31db505 MC |
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. | |
cc99526d | 61 | |
0bc6597d LJ |
62 | =head1 SEE ALSO |
63 | ||
b97fdb57 | 64 | L<ssl(7)>, L<SSL_get_session(3)>, |
9b86974e RS |
65 | L<SSL_CTX_set_session_cache_mode(3)>, |
66 | L<SSL_CTX_flush_sessions(3)>, | |
67 | L<d2i_SSL_SESSION(3)> | |
cc99526d | 68 | |
e2f92610 RS |
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 |