5 SSL_shutdown - shut down a TLS/SSL connection
9 #include <openssl/ssl.h>
11 int SSL_shutdown(SSL *ssl);
15 SSL_shutdown() shuts down an active TLS/SSL connection. It sends the
16 "close notify" shutdown alert to the peer.
20 SSL_shutdown() tries to send the "close notify" shutdown alert to the peer.
21 Whether the operation succeeds or not, the SSL_SENT_SHUTDOWN flag is set and
22 a currently open session is considered closed and good and will be kept in the
23 session cache for further reuse.
25 The behaviour of SSL_shutdown() depends on the underlying BIO.
27 If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the
28 handshake has been finished or an error occurred.
30 If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return
31 when the underlying BIO could not satisfy the needs of SSL_shutdown()
32 to continue the handshake. In this case a call to SSL_get_error() with the
33 return value of SSL_shutdown() will yield B<SSL_ERROR_WANT_READ> or
34 B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
35 taking appropriate action to satisfy the needs of SSL_shutdown().
36 The action depends on the underlying BIO. When using a non-blocking socket,
37 nothing is to be done, but select() can be used to check for the required
38 condition. When using a buffering BIO, like a BIO pair, data must be written
39 into or retrieved out of the BIO before being able to continue.
43 The following return values can occur:
49 The shutdown was successfully completed.
53 The shutdown was not successful. Call SSL_get_error() with the return
54 value B<ret> to find out the reason.
58 The shutdown was not successful because a fatal error occurred either
59 at the protocol level or a connection failure occurred. It can also occur of
60 action is need to continue the operation for non-blocking BIOs.
61 Call SSL_get_error() with the return value B<ret> to find out the reason.
67 L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
68 L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
69 L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>,
70 L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>