SSL_FREE(3)
π SSL_FREE(3) π
okay so this is a page from the Library Functions Manual bestie, and it's literally all about SSL_free β the little cleanup queen of libssl. she's iconic, she's necessary, and if you ignore her you WILL leak memory. iykyk π
β¨ NAME β¨
SSL_free β free an allocated SSL structure π¦ (yes that's it, that's the whole job, and she does it flawlessly)
β¨ SYNOPSIS β¨
so you're gonna need libssl and libcrypto, and you include this:
#include <openssl/ssl.h>
void
SSL_free(SSL *ssl);
that's her. one function. one pointer. no cap. π«Ά
π DESCRIPTION π
okay so here's the tea, bestie πΈ β SSL_free() decrements the reference count of ssl, and then actually removes the SSL structure pointed to by ssl and frees up the allocated memory β but ONLY once the reference count has reached 0. like she's not gonna just nuke it while other people are still using it, that would be rude.
and if ssl is a NULL pointer? no action occurs. literally nothing. she just vibes. β¨
now here's the part where it gets kinda extra β SSL_free() ALSO calls the free(3)-ing procedures for all the indirectly affected items, if applicable π:
- the buffering BIO
- the read and write BIOs
- the cipher lists specially created for this
ssl - the
SSL_SESSION
β οΈ and this is the important bit, do NOT come for these, bestie β do not explicitly free these indirectly freed up items before or after calling SSL_free(). because trying to free things twice may lead to program failure. and not the cute kind of failure. the segfault kind. ππ
also, the ssl session has reference counts from two users, keep up π₯:
- the
SSLobject β for which the reference count is removed bySSL_free() - the internal session cache
and here's a fun little rule: 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 RFC 2246. yes, RFC 2246. she read the docs so you don't have to. β
π SEE ALSO π
go read those too, they're giving main character energy π§π
π HISTORY π
SSL_free() appeared in SSLeay 0.4 or earlier and has been available since OpenBSD 2.4. she's been here since basically forever and she's still slaying. periodt. π
and that's the whole page diva! π this gem came from Debian, dated June 8, 2025 β mwah, go free your SSL structs responsibly πβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2001 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms