SSL_shutdown - shut down a TLS/SSL connection
SYNOPSIS
#include <openssl/ssl.h>
int SSL_shutdown(SSL *ssl);
DESCRIPTION
SSL_shutdown() shuts down an active TLS/SSL connection. It
sends the "close notify" shutdown alert to the peer.
NOTES
SSL_shutdown() tries to send the "close notify" shutdown
alert to the peer. Whether the operation succeeds or not,
the SSL_SENT_SHUTDOWN flag is set and a currently open
session is considered closed and good and will be kept in
the session cache for further reuse.
The behaviour of SSL_shutdown() depends on the underlying
BIO.
If the underlying BIO is blocking, SSL_shutdown() will
only return once the handshake has been finished or an
error occurred.
If the underlying BIO is non-blocking, SSL_shutdown() will
also return when the underlying BIO could not satisfy the
needs of SSL_shutdown() to continue the handshake. In this
case a call to SSL_get_error() with the return value of
SSL_shutdown() will yield SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE. The calling process then must repeat
the call after taking appropriate action to satisfy the
needs of SSL_shutdown(). The action depends on the
underlying BIO. When using a non-blocking socket, nothing
is to be done, but select() can be used to check for the
required condition. When using a buffering BIO, like a BIO
pair, data must be written into or retrieved out of the
BIO before being able to continue.
RETURN VALUES
The following return values can occur:
1 The shutdown was successfully completed.
0 The shutdown was not successful. Call SSL_get_error()
with the return value ret to find out the reason.
-1 The shutdown was not successful because a fatal error
occurred either at the protocol level or a connection
failure occurred. It can also occur of action is need
to continue the operation for non-blocking BIOs. Call
SSL_get_error() with the return value ret to find out
SEE ALSO
SSL_get_error(3), SSL_connect(3), SSL_accept(3),
SSL_set_shutdown(3), SSL_clear(3), SSL_free(3), ssl(3),
bio(3)
Man(1) output converted with
man2html