diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libssl/src/doc/ssl/SSL_shutdown.pod | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libssl/src/doc/ssl/SSL_shutdown.pod')
-rw-r--r-- | src/lib/libssl/src/doc/ssl/SSL_shutdown.pod | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod index c4ae6704e7..6b5012be7a 100644 --- a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod +++ b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod | |||
@@ -22,10 +22,52 @@ 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 | 22 | a currently open session is considered closed and good and will be kept in the |
23 | session cache for further reuse. | 23 | session cache for further reuse. |
24 | 24 | ||
25 | The behaviour of SSL_shutdown() depends on the underlying BIO. | 25 | The shutdown procedure consists of 2 steps: the sending of the "close notify" |
26 | shutdown alert and the reception of the peer's "close notify" shutdown | ||
27 | alert. According to the TLS standard, it is acceptable for an application | ||
28 | to only send its shutdown alert and then close the underlying connection | ||
29 | without waiting for the peer's response (this way resources can be saved, | ||
30 | as the process can already terminate or serve another connection). | ||
31 | When the underlying connection shall be used for more communications, the | ||
32 | complete shutdown procedure (bidirectional "close notify" alerts) must be | ||
33 | performed, so that the peers stay synchronized. | ||
34 | |||
35 | SSL_shutdown() supports both uni- and bidirectional shutdown by its 2 step | ||
36 | behaviour. | ||
37 | |||
38 | =over 4 | ||
39 | |||
40 | =item When the application is the first party to send the "close notify" | ||
41 | alert, SSL_shutdown() will only send the alert and the set the | ||
42 | SSL_SENT_SHUTDOWN flag (so that the session is considered good and will | ||
43 | be kept in cache). SSL_shutdown() will then return with 0. If a unidirectional | ||
44 | shutdown is enough (the underlying connection shall be closed anyway), this | ||
45 | first call to SSL_shutdown() is sufficient. In order to complete the | ||
46 | bidirectional shutdown handshake, SSL_shutdown() must be called again. | ||
47 | The second call will make SSL_shutdown() wait for the peer's "close notify" | ||
48 | shutdown alert. On success, the second call to SSL_shutdown() will return | ||
49 | with 1. | ||
50 | |||
51 | =item If the peer already sent the "close notify" alert B<and> it was | ||
52 | already processed implicitly inside another function | ||
53 | (L<SSL_read(3)|SSL_read(3)>), the SSL_RECEIVED_SHUTDOWN flag is set. | ||
54 | SSL_shutdown() will send the "close notify" alert, set the SSL_SENT_SHUTDOWN | ||
55 | flag and will immediately return with 1. | ||
56 | Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the | ||
57 | SSL_get_shutdown() (see also L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> call. | ||
58 | |||
59 | =back | ||
60 | |||
61 | It is therefore recommended, to check the return value of SSL_shutdown() | ||
62 | and call SSL_shutdown() again, if the bidirectional shutdown is not yet | ||
63 | complete (return value of the first call is 0). As the shutdown is not | ||
64 | specially handled in the SSLv2 protocol, SSL_shutdown() will succeed on | ||
65 | the first call. | ||
66 | |||
67 | The behaviour of SSL_shutdown() additionally depends on the underlying BIO. | ||
26 | 68 | ||
27 | If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the | 69 | If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the |
28 | handshake has been finished or an error occurred. | 70 | handshake step has been finished or an error occurred. |
29 | 71 | ||
30 | If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return | 72 | 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() | 73 | when the underlying BIO could not satisfy the needs of SSL_shutdown() |
@@ -38,6 +80,12 @@ 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 | 80 | 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. | 81 | into or retrieved out of the BIO before being able to continue. |
40 | 82 | ||
83 | SSL_shutdown() can be modified to only set the connection to "shutdown" | ||
84 | state but not actually send the "close notify" alert messages, | ||
85 | see L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>. | ||
86 | When "quiet shutdown" is enabled, SSL_shutdown() will always succeed | ||
87 | and return 1. | ||
88 | |||
41 | =head1 RETURN VALUES | 89 | =head1 RETURN VALUES |
42 | 90 | ||
43 | The following return values can occur: | 91 | The following return values can occur: |
@@ -46,19 +94,23 @@ The following return values can occur: | |||
46 | 94 | ||
47 | =item 1 | 95 | =item 1 |
48 | 96 | ||
49 | The shutdown was successfully completed. | 97 | The shutdown was successfully completed. The "close notify" alert was sent |
98 | and the peer's "close notify" alert was received. | ||
50 | 99 | ||
51 | =item 0 | 100 | =item 0 |
52 | 101 | ||
53 | The shutdown was not successful. Call SSL_get_error() with the return | 102 | The shutdown is not yet finished. Call SSL_shutdown() for a second time, |
54 | value B<ret> to find out the reason. | 103 | if a bidirectional shutdown shall be performed. |
104 | The output of L<SSL_get_error(3)|SSL_get_error(3)> may be misleading, as an | ||
105 | erroneous SSL_ERROR_SYSCALL may be flagged even though no error occurred. | ||
55 | 106 | ||
56 | =item -1 | 107 | =item -1 |
57 | 108 | ||
58 | The shutdown was not successful because a fatal error occurred either | 109 | 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 | 110 | at the protocol level or a connection failure occurred. It can also occur if |
60 | action is need to continue the operation for non-blocking BIOs. | 111 | 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. | 112 | Call L<SSL_get_error(3)|SSL_get_error(3)> with the return value B<ret> |
113 | to find out the reason. | ||
62 | 114 | ||
63 | =back | 115 | =back |
64 | 116 | ||
@@ -66,6 +118,7 @@ Call SSL_get_error() with the return value B<ret> to find out the reason. | |||
66 | 118 | ||
67 | L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>, | 119 | 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)>, | 120 | L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, |
121 | L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>, | ||
69 | L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>, | 122 | 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)> | 123 | L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)> |
71 | 124 | ||