---
name: "libressl-SSL_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_free"
---

# libressl-SSL\_free(3)

free an allocated SSL structure

## NAME

**SSL\_free** – free an allocated SSL structure

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

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

*void*\

**SSL\_free**(*SSL \*ssl*);

## DESCRIPTION

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

**SSL\_free**() also calls the[free(3)](/free/3.md) 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**. Do not explicitly free these indirectly freed up items before or after calling **SSL\_free**(), as trying to free things twice may lead to program failure.

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. 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, the session will also be removed from the session cache as required by RFC 2246.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_clear(3), SSL\_new(3), SSL\_set\_shutdown(3), SSL\_shutdown(3)

## HISTORY

**SSL\_free**() appeared in SSLeay 0.4 or earlier and has been available since OpenBSD 2.4.
