SSL_CTX_FREE(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸŽ€ NAME πŸŽ€

SSL_CTX_free β€” free an allocated SSL_CTX object. That’s the whole assignment, bestie. This is the SSL_CTX_FREE(3) page from the Library Functions Manual, and we’re gonna get into it.


✨ SYNOPSIS ✨

library β€œlibssl” libcrypto #include <openssl/ssl.h>

void
SSL_CTX_free(SSL_CTX *ctx);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so SSL_CTX_free() decrements the reference count of ctx. If that reference count has reached 0, it removes the SSL_CTX object pointed to by ctx and frees up the allocated memory. Very β€œyour fave is leaving the group chat” energy, but make it memory management. 🫢

And no cap: if ctx is a NULL pointer, no action occurs. Nothing happens. We love a safe little no-op moment.

When applicable, it also calls the free(3)-ing procedures for indirectly affected items:

  • the session cache
  • the list of ciphers
  • the list of Client CAs
  • the certificates
  • the keys

😭 WARNINGS 😭

Bestie, read this part twice. If a session-remove callback is set β€” as in SSL_CTX_sess_set_remove_cb(3) β€” that callback will be called for each session being freed from ctx's session cache. This implies that all corresponding sessions from an external session cache are removed as well. That’s a big deal, ngl.

If that is not what you want, the user should explicitly unset the callback by calling SSL_CTX_sess_set_remove_cb(ctx, NULL) prior to calling SSL_CTX_free(). Periodt. Don’t skip the cleanup step and then act surprised. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

🧚 HISTORY 🧚

SSL_CTX_free() first appeared in SSLeay 0.5.1 and has been available since OpenBSD 2.4. The way this function is literally older than most of our fave aesthetics? Iconic.


Cute little sign-off for the footer vibes: Debian β€’ June 8, 2025 β€’ SSL_CTX_FREE(3) πŸ’…βœ¨

πŸ“¦ where this page comes from