SSL_CTX_FREE(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… SSL_CTX_FREE β€” free an allocated SSL_CTX object πŸŽ€

okay bestie, so this is the 3ossl manual page (that's the OpenSSL section of the man pages, iykyk) and it's literally the "bye bye" button for your SSL_CTX object ✨


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

void SSL_CTX_free(SSL_CTX *ctx);

one include, one function, zero drama. slay.


🌸 DESCRIPTION 🌸

SSL_CTX_free() is the one that decrements the reference count of ctx πŸ‘‘ β€” and if that count has hit 0, it removes the SSL_CTX object pointed to by ctx and frees up all the allocated memory. so it's like, the polite way to say goodbye 🫢

not only that but it also calls the free()ing procedures for the indirectly affected items, if applicable β€” which is honestly giving responsible main character energy πŸ’…:

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

and if ctx is NULL? nothing is done. it just vibes. literally nothing happens, no crash, no tears 😌


⚠️ WARNINGS ⚠️

okay listen up bestie, this part matters fr fr πŸ”₯

If a session-remove callback is set (via SSL_CTX_sess_set_remove_cb()), this callback will be called for each session being freed from ctx's session cache. and that implies something kind of wild 😭: all corresponding sessions from an external session cache get removed as well.

so if that's not what you want β€” if you're sitting there like "not me accidentally nuking my external session cache" πŸ’€ β€” the user should explicitly unset the callback by calling

SSL_CTX_sess_set_remove_cb(ctx, NULL)

before calling SSL_CTX_free(). order matters, no cap πŸ™ˆ


πŸ¦‹ RETURN VALUES πŸ¦‹

SSL_CTX_free() does not provide diagnostic information.

that's it. it's void. it gives you nothing back. no status, no error code, no little note saying "hey bestie that worked" πŸ’€ she simply handles her business and leaves.


🌈 SEE ALSO 🌈

like, obviously you need SSL_CTX_new(3) β€” can't free what you never made, iconically πŸŽ€


Copyright 2000-2016 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're officially caught up πŸ’œ this was OpenSSL 3.5.6, dated 2026-04-07 β€” go forth and free your contexts responsibly, bestie ✨🌸🫢

πŸ“¦ where this page comes from