SSL_FREE(3ossl)
π SSL_FREE(3ossl) β bestie, it's time to let go π
okay so this is page SSL_FREE from the OpenSSL manual, section 3ossl β yes it's giving β¨reference materialβ¨ but honestly it's short and it slaps, so stay with me π«Ά
πΈ NAME πΈ
SSL_free β free an allocated SSL structure π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
void SSL_free(SSL *ssl);
π¦ DESCRIPTION π¦
SSL_free() decrements the reference count of ssl, and it removes the SSL structure pointed to by ssl and frees up the allocated memory if and only if the reference count has reached 0. That's the whole vibe check π₯
And if ssl is NULL? Nothing happens. Not a thing. Zero. Nada. The function just looks at you and moves on π
π NOTES π
okay this is the part where you actually pay attention bestie, because SSL_free() is not just freeing one lil object. It also calls the free()ing procedures for indirectly affected items, if applicable:
- the buffering BIO π
- the read and write BIOs π
- cipher lists specially created for this
sslπ - the
SSL_SESSIONπ
π¨ DO NOT explicitly free these indirectly freed up items before or after calling SSL_free(). Trying to free things twice may lead to program failure. Double-free is not the moment, bestie, it's the villain arc π
π the session refcount situation π
The ssl session has reference counts from two users:
- the
SSLobject, for which the reference count is removed bySSL_free() - the internal session cache
If the session is considered bad β because SSL_shutdown(3) was not called for the connection and SSL_set_shutdown(3) was not used to set the SSL_SENT_SHUTDOWN state β then the session will also be removed from the session cache, as required by RFC2246. Rules are rules, no cap π
π§ the QUIC stream situation π§
When used to free a QUIC stream SSL object</u>, the respective sending and receiving parts of the stream are reset β unless those parts have already been concluded normally. Let's break it down:
- If the stream has a sending part (in other words, if it is bidirectional or a locally-initiated unidirectional stream) and that part has not been concluded via a call to
SSL_stream_conclude(3)orSSL_stream_reset(3)on the QUIC stream SSL object, a call toSSL_free()automatically resets the sending part of the stream as thoughSSL_stream_reset(3)were called with a QUIC application error code of0. - If the stream has a receiving part (in other words, if it is bidirectional or a remotely-initiated unidirectional stream), and the peer has not yet concluded that part of the stream normally (such as via a call to
SSL_stream_conclude(3)on its own end), a call toSSL_free()automatically requests the reset of the receiving part of the stream using a QUICSTOP_SENDINGframe with a QUIC application error code of0. And note that as per the QUIC protocol, this will automatically cause the peer to reset that part of the stream in turn β which is its sending part. Chain reaction, it's giving dominoes π’π’π’
Also very important: a QUIC stream SSL object maintains a reference to a QUIC connection SSL object internally, therefore a QUIC stream SSL object and its parent QUIC connection SSL object can be freed in either order. No strict rules about who goes first, we're chill like that π
π RETURN VALUES π
SSL_free() does not provide diagnostic information. That's it, that's the return value section β it gives you nothing, and honestly? respect the mystery π
If you wanna keep reading (and you should, bestie), go peep SSL_new(3), SSL_clear(3), SSL_shutdown(3), SSL_set_shutdown(3), and ssl(7) π
β COPYRIGHT β
Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved. π
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay that's the whole page, you ate it, you're a memory-management main character now π
β¨ this was OpenSSL 3.5.9, dated 2026-09-29, and it's filed under SSL_FREE(3ossl). go forth and free responsibly, bestie β and never twice ππ¦πΈ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms