---
name: "SSL_set_shutdown"
section: "3ssl"
platform: "linux"
package: "openssl"
version: "3.6.5-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SSL_set_shutdown"
---

# SSL\_set\_shutdown(3ssl)

manipulate shutdown state of an SSL connection

## NAME

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

## SYNOPSIS

```
 #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**.

## NOTES

The shutdown state of an ssl connection is a bit-mask 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 form 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 RFC2246. 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, for setting SSL\_SENT\_SHUTDOWN the application must however still call **SSL\_shutdown**(3) or **SSL\_set\_shutdown()** itself.

**SSL\_set\_shutdown()** is not supported for QUIC SSL objects.

## RETURN VALUES

**SSL\_set\_shutdown()** does not return diagnostic information.

**SSL\_get\_shutdown()** returns the current shutdown state as set or based on the actual connection state.

**SSL\_get\_shutdown()** returns 0 if called on a QUIC stream SSL object. If it is called on a QUIC connection SSL object, it returns a value with SSL\_SENT\_SHUTDOWN set if CONNECTION\_CLOSE has been sent to the peer and it returns a value with SSL\_RECEIVED\_SHUTDOWN set if CONNECTION\_CLOSE has been received from the peer or the QUIC connection is fully terminated for other reasons.

## SEE ALSO

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

## COPYRIGHT

Copyright 2001-2023 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\>.
