SSL_FREE(3SSL)
π SSL_FREE β free an allocated SSL structure π
okay bestie, welcome to SSL_free() from the OpenSSL fam β it's the 3SSL manual page, and today we're learning how to say goodbye to an SSL structure properly. no dramatic exits, no double-frees, just clean closure. π
β¨ NAME β¨
SSL_free β free an allocated SSL structure
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
void SSL_free(SSL *ssl);
π¦ DESCRIPTION π¦
so here's the tea: 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 the reference count has reached 0. like, the structure only truly leaves the group chat when nobody's holding a ref anymore. π
and if ssl is NULL? literally nothing happens. nothing is done. it's giving ghosting. π»
π NOTES π
not me dropping the most important part β SSL_free() is not just here for the main character. 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ποΈ
bestie PLEASE β 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 cute, it is a crime scene. π
okay so bout the session β the ssl session has reference counts from two users: the SSL object, for which the reference count is removed by SSL_free(), and the internal session cache. and 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. the lore is documented, periodt. π
π§ QUIC stream tea (when you free a QUIC stream SSL object) π§
when you use SSL_free() to free a QUIC stream SSL object, the respective sending and receiving parts of the stream are reset unless those parts have already been concluded normally:
- 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. bye felicia π - 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. 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). the drama cascades, iykyk π
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 "you first", no "no you first" β both orders slay. π«Ά
π RETURN VALUES π
SSL_free() does not provide diagnostic information. it's not gonna tell you how it went, it's not gonna text back, it just does the thing. silence is the vibe. π
π SEE ALSO π
SSL_new(3), SSL_clear(3), SSL_shutdown(3), SSL_set_shutdown(3), 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>.
and that's the whole page bestie, you ATE that documentation. this was OpenSSL 4.0.3, dated 2026-09-29, filed under SSL_FREE(3SSL) β now go free your pointers responsibly, mwah ππβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms