xref: /openssl/doc/man3/SSL_free.pod (revision da1c088f)
1=pod
2
3=head1 NAME
4
5SSL_free - free an allocated SSL structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_free(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_free() decrements the reference count of B<ssl>, and removes the SSL
16structure pointed to by B<ssl> and frees up the allocated memory if the
17reference count has reached 0.
18If B<ssl> is NULL nothing is done.
19
20=head1 NOTES
21
22SSL_free() also calls the free()ing procedures for indirectly affected items, if
23applicable: the buffering BIO, the read and write BIOs,
24cipher lists specially created for this B<ssl>, the B<SSL_SESSION>.
25Do not explicitly free these indirectly freed up items before or after
26calling SSL_free(), as trying to free things twice may lead to program
27failure.
28
29The ssl session has reference counts from two users: the SSL object, for
30which the reference count is removed by SSL_free() and the internal
31session cache. If the session is considered bad, because
32L<SSL_shutdown(3)> was not called for the connection
33and L<SSL_set_shutdown(3)> was not used to set the
34SSL_SENT_SHUTDOWN state, the session will also be removed
35from the session cache as required by RFC2246.
36
37When used to free a QUIC stream SSL object, the respective sending and receiving
38parts of the stream are reset unless those parts have already been concluded
39normally:
40
41=over 4
42
43=item
44
45If the stream has a sending part (in other words, if it is bidirectional or a
46locally-initiated unidirectional stream) and that part has not been concluded
47via a call to L<SSL_stream_conclude(3)> or L<SSL_stream_reset(3)> on the QUIC
48stream SSL object, a call to SSL_free() automatically resets the sending part of
49the stream as though L<SSL_stream_reset(3)> were called with a QUIC application
50error code of 0.
51
52=item
53
54If the stream has a receiving part (in other words, if it is bidirectional or a
55remotely-initiated unidirectional stream), and the peer has not yet concluded
56that part of the stream normally (such as via a call to
57L<SSL_stream_conclude(3)> on its own end), a call to SSL_free() automatically
58requests the reset of the receiving part of the stream using a QUIC STOP_SENDING
59frame with a QUIC application error code of 0. Note that as per the QUIC
60protocol, this will automatically cause the peer to reset that part of the
61stream in turn (which is its sending part).
62
63=back
64
65A QUIC stream SSL object maintains a reference to a QUIC connection SSL object
66internally, therefore a QUIC stream SSL object and its parent QUIC connection
67SSL object can be freed in either order.
68
69=head1 RETURN VALUES
70
71SSL_free() does not provide diagnostic information.
72
73L<SSL_new(3)>, L<SSL_clear(3)>,
74L<SSL_shutdown(3)>, L<SSL_set_shutdown(3)>,
75L<ssl(7)>
76
77=head1 COPYRIGHT
78
79Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
80
81Licensed under the Apache License 2.0 (the "License").  You may not use
82this file except in compliance with the License.  You can obtain a copy
83in the file LICENSE in the source distribution or at
84L<https://www.openssl.org/source/license.html>.
85
86=cut
87