---
name: "libressl-SSL_set_shutdown"
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_set_shutdown"
---

# libressl-SSL\_set\_shutdown(3)

manipulate shutdown state of an SSL connection

## NAME

**SSL\_set\_shutdown**, **SSL\_get\_shutdown** – manipulate shutdown state of an SSL connection

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

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

*void*\

**SSL\_set\_shutdown**(*SSL \*ssl*, *int mode*);

*int*\

**SSL\_get\_shutdown**(*const SSL \*ssl*);

## DESCRIPTION

**SSL\_set\_shutdown**() sets the shutdown state of *ssl* to *mode*.

**SSL\_get\_shutdown**() returns the shutdown mode of *ssl*.

The shutdown state of an ssl connection is a bitmask of:

- 0

  No shutdown setting, yet.

- SSL\_SENT\_SHUTDOWN

  A “close notify” shutdown alert was sent to the peer; the connection is being considered closed and the session is closed and correct.

- SSL\_RECEIVED\_SHUTDOWN

  A shutdown alert was received from the peer, either a normal “close notify” or a fatal error.

SSL\_SENT\_SHUTDOWN and SSL\_RECEIVED\_SHUTDOWN can be set at the same time.

The shutdown state of the connection is used to determine the state of the *ssl* session. If the session is still open when SSL\_clear(3) or SSL\_free(3) is called, it is considered bad and removed according to RFC 2246. The actual condition for a correctly closed session is SSL\_SENT\_SHUTDOWN (according to the TLS RFC, it is acceptable to only send the “close notify” alert but to not wait for the peer's answer when the underlying connection is closed). **SSL\_set\_shutdown**() can be used to set this state without sending a close alert to the peer (see SSL\_shutdown(3)).

If a “close notify” was received, SSL\_RECEIVED\_SHUTDOWN will be set, but to set SSL\_SENT\_SHUTDOWN the application must still call SSL\_shutdown(3) or **SSL\_set\_shutdown**() itself.

## RETURN VALUES

**SSL\_get\_shutdown**() returns the current setting.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_clear(3), SSL\_CTX\_set\_quiet\_shutdown(3), SSL\_free(3), SSL\_shutdown(3)

## HISTORY

**SSL\_set\_shutdown**() and **SSL\_get\_shutdown**() first appeared in SSLeay 0.8.0 and have been available since OpenBSD 2.4.
