---
name: "libressl-SSL_CTX_free"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-SSL_CTX_free"
---

# libressl-SSL\_CTX\_free(3)

free an allocated SSL\_CTX object

## NAME

**SSL\_CTX\_free** – free an allocated SSL\_CTX object

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

**#include \<openssl/ssl.h\>**

*void*\

**SSL\_CTX\_free**(*SSL\_CTX \*ctx*);

## DESCRIPTION

**SSL\_CTX\_free**() decrements the reference count of *ctx*, and removes the *SSL\_CTX* object pointed to by *ctx* and frees up the allocated memory if the reference count has reached 0. If *ctx* is a NULL pointer, no action occurs.

It also calls the [free(3)](/free/3.md)ing procedures for indirectly affected items, if applicable: the session cache, the list of ciphers, the list of Client CAs, the certificates and keys.

## WARNINGS

If a session-remove callback is set (SSL\_CTX\_sess\_set\_remove\_cb(3)), this 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. If this is not desired, the user should explicitly unset the callback by calling **SSL\_CTX\_sess\_set\_remove\_cb**(*ctx*, *NULL*) prior to calling **SSL\_CTX\_free**().

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_CTX\_new(3), SSL\_CTX\_sess\_set\_get\_cb(3)

## HISTORY

**SSL\_CTX\_free**() first appeared in SSLeay 0.5.1 and has been available since OpenBSD 2.4.
