xref: /freebsd/crypto/openssl/doc/man3/SSL_SESSION_free.pod (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
1*e71b7053SJung-uk Kim=pod
2*e71b7053SJung-uk Kim
3*e71b7053SJung-uk Kim=head1 NAME
4*e71b7053SJung-uk Kim
5*e71b7053SJung-uk KimSSL_SESSION_new,
6*e71b7053SJung-uk KimSSL_SESSION_dup,
7*e71b7053SJung-uk KimSSL_SESSION_up_ref,
8*e71b7053SJung-uk KimSSL_SESSION_free - create, free and manage SSL_SESSION structures
9*e71b7053SJung-uk Kim
10*e71b7053SJung-uk Kim=head1 SYNOPSIS
11*e71b7053SJung-uk Kim
12*e71b7053SJung-uk Kim #include <openssl/ssl.h>
13*e71b7053SJung-uk Kim
14*e71b7053SJung-uk Kim SSL_SESSION *SSL_SESSION_new(void);
15*e71b7053SJung-uk Kim SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src);
16*e71b7053SJung-uk Kim int SSL_SESSION_up_ref(SSL_SESSION *ses);
17*e71b7053SJung-uk Kim void SSL_SESSION_free(SSL_SESSION *session);
18*e71b7053SJung-uk Kim
19*e71b7053SJung-uk Kim=head1 DESCRIPTION
20*e71b7053SJung-uk Kim
21*e71b7053SJung-uk KimSSL_SESSION_new() creates a new SSL_SESSION structure and returns a pointer to
22*e71b7053SJung-uk Kimit.
23*e71b7053SJung-uk Kim
24*e71b7053SJung-uk KimSSL_SESSION_dup() copies the contents of the SSL_SESSION structure in B<src>
25*e71b7053SJung-uk Kimand returns a pointer to it.
26*e71b7053SJung-uk Kim
27*e71b7053SJung-uk KimSSL_SESSION_up_ref() increments the reference count on the given SSL_SESSION
28*e71b7053SJung-uk Kimstructure.
29*e71b7053SJung-uk Kim
30*e71b7053SJung-uk KimSSL_SESSION_free() decrements the reference count of B<session> and removes
31*e71b7053SJung-uk Kimthe B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated
32*e71b7053SJung-uk Kimmemory, if the reference count has reached 0.
33*e71b7053SJung-uk KimIf B<session> is NULL nothing is done.
34*e71b7053SJung-uk Kim
35*e71b7053SJung-uk Kim=head1 NOTES
36*e71b7053SJung-uk Kim
37*e71b7053SJung-uk KimSSL_SESSION objects are allocated, when a TLS/SSL handshake operation
38*e71b7053SJung-uk Kimis successfully completed. Depending on the settings, see
39*e71b7053SJung-uk KimL<SSL_CTX_set_session_cache_mode(3)>,
40*e71b7053SJung-uk Kimthe SSL_SESSION objects are internally referenced by the SSL_CTX and
41*e71b7053SJung-uk Kimlinked into its session cache. SSL objects may be using the SSL_SESSION object;
42*e71b7053SJung-uk Kimas a session may be reused, several SSL objects may be using one SSL_SESSION
43*e71b7053SJung-uk Kimobject at the same time. It is therefore crucial to keep the reference
44*e71b7053SJung-uk Kimcount (usage information) correct and not delete a SSL_SESSION object
45*e71b7053SJung-uk Kimthat is still used, as this may lead to program failures due to
46*e71b7053SJung-uk Kimdangling pointers. These failures may also appear delayed, e.g.
47*e71b7053SJung-uk Kimwhen an SSL_SESSION object was completely freed as the reference count
48*e71b7053SJung-uk Kimincorrectly became 0, but it is still referenced in the internal
49*e71b7053SJung-uk Kimsession cache and the cache list is processed during a
50*e71b7053SJung-uk KimL<SSL_CTX_flush_sessions(3)> operation.
51*e71b7053SJung-uk Kim
52*e71b7053SJung-uk KimSSL_SESSION_free() must only be called for SSL_SESSION objects, for
53*e71b7053SJung-uk Kimwhich the reference count was explicitly incremented (e.g.
54*e71b7053SJung-uk Kimby calling SSL_get1_session(), see L<SSL_get_session(3)>)
55*e71b7053SJung-uk Kimor when the SSL_SESSION object was generated outside a TLS handshake
56*e71b7053SJung-uk Kimoperation, e.g. by using L<d2i_SSL_SESSION(3)>.
57*e71b7053SJung-uk KimIt must not be called on other SSL_SESSION objects, as this would cause
58*e71b7053SJung-uk Kimincorrect reference counts and therefore program failures.
59*e71b7053SJung-uk Kim
60*e71b7053SJung-uk Kim=head1 RETURN VALUES
61*e71b7053SJung-uk Kim
62*e71b7053SJung-uk KimSSL_SESSION_new returns a pointer to the newly allocated SSL_SESSION structure
63*e71b7053SJung-uk Kimor NULL on error.
64*e71b7053SJung-uk Kim
65*e71b7053SJung-uk KimSSL_SESSION_up_ref returns 1 on success or 0 on error.
66*e71b7053SJung-uk Kim
67*e71b7053SJung-uk Kim=head1 SEE ALSO
68*e71b7053SJung-uk Kim
69*e71b7053SJung-uk KimL<ssl(7)>, L<SSL_get_session(3)>,
70*e71b7053SJung-uk KimL<SSL_CTX_set_session_cache_mode(3)>,
71*e71b7053SJung-uk KimL<SSL_CTX_flush_sessions(3)>,
72*e71b7053SJung-uk KimL<d2i_SSL_SESSION(3)>
73*e71b7053SJung-uk Kim
74*e71b7053SJung-uk Kim=head1 HISTORY
75*e71b7053SJung-uk Kim
76*e71b7053SJung-uk KimSSL_SESSION_dup() was added in OpenSSL 1.1.1.
77*e71b7053SJung-uk Kim
78*e71b7053SJung-uk Kim=head1 COPYRIGHT
79*e71b7053SJung-uk Kim
80*e71b7053SJung-uk KimCopyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
81*e71b7053SJung-uk Kim
82*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
83*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
84*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
85*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
86*e71b7053SJung-uk Kim
87*e71b7053SJung-uk Kim=cut
88