diff options
author | bentley <> | 2014-10-12 09:33:04 +0000 |
---|---|---|
committer | bentley <> | 2014-10-12 09:33:04 +0000 |
commit | 82b7f378b6907ab315a6e50322d2a0a8794a0aa9 (patch) | |
tree | a5087bf8d016a6041c2b6822fbecfd8f6c5e70b1 /src/lib/libssl/doc/SSL_shutdown.3 | |
parent | 0a63f0cf49369e1926567ab62e04e3355cedf0cd (diff) | |
download | openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.gz openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.bz2 openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.zip |
Convert libssl manpages from pod to mdoc(7).
libcrypto has not been started yet.
ok schwarze@ miod@
Diffstat (limited to 'src/lib/libssl/doc/SSL_shutdown.3')
-rw-r--r-- | src/lib/libssl/doc/SSL_shutdown.3 | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_shutdown.3 b/src/lib/libssl/doc/SSL_shutdown.3 new file mode 100644 index 0000000000..aa8d483b24 --- /dev/null +++ b/src/lib/libssl/doc/SSL_shutdown.3 | |||
@@ -0,0 +1,201 @@ | |||
1 | .Dd $Mdocdate: October 12 2014 $ | ||
2 | .Dt SSL_SHUTDOWN 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm SSL_shutdown | ||
6 | .Nd shut down a TLS/SSL connection | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/ssl.h | ||
9 | .Ft int | ||
10 | .Fn SSL_shutdown "SSL *ssl" | ||
11 | .Sh DESCRIPTION | ||
12 | .Fn SSL_shutdown | ||
13 | shuts down an active TLS/SSL connection. | ||
14 | It sends the | ||
15 | .Dq close notify | ||
16 | shutdown alert to the peer. | ||
17 | .Sh NOTES | ||
18 | .Fn SSL_shutdown | ||
19 | tries to send the | ||
20 | .Dq close notify | ||
21 | shutdown alert to the peer. | ||
22 | Whether the operation succeeds or not, the | ||
23 | .Dv SSL_SENT_SHUTDOWN | ||
24 | flag is set and a currently open session is considered closed and good and will | ||
25 | be kept in the session cache for further reuse. | ||
26 | .Pp | ||
27 | The shutdown procedure consists of 2 steps: the sending of the | ||
28 | .Dq close notify | ||
29 | shutdown alert and the reception of the peer's | ||
30 | .Dq close notify | ||
31 | shutdown alert. | ||
32 | According to the TLS standard, it is acceptable for an application to only send | ||
33 | its shutdown alert and then close the underlying connection without waiting for | ||
34 | the peer's response (this way resources can be saved, as the process can | ||
35 | already terminate or serve another connection). | ||
36 | When the underlying connection shall be used for more communications, | ||
37 | the complete shutdown procedure (bidirectional | ||
38 | .Dq close notify | ||
39 | alerts) must be performed, so that the peers stay synchronized. | ||
40 | .Pp | ||
41 | .Fn SSL_shutdown | ||
42 | supports both uni- and bidirectional shutdown by its 2 step behavior. | ||
43 | .Pp | ||
44 | When the application is the first party to send the | ||
45 | .Dq close notify | ||
46 | alert, | ||
47 | .Fn SSL_shutdown | ||
48 | will only send the alert and then set the | ||
49 | .Dv SSL_SENT_SHUTDOWN | ||
50 | flag (so that the session is considered good and will be kept in cache). | ||
51 | .Fn SSL_shutdown | ||
52 | will then return 0. | ||
53 | If a unidirectional shutdown is enough | ||
54 | (the underlying connection shall be closed anyway), this first call to | ||
55 | .Fn SSL_shutdown | ||
56 | is sufficient. | ||
57 | In order to complete the bidirectional shutdown handshake, | ||
58 | .Fn SSL_shutdown | ||
59 | must be called again. | ||
60 | The second call will make | ||
61 | .Fn SSL_shutdown | ||
62 | wait for the peer's | ||
63 | .Dq close notify | ||
64 | shutdown alert. | ||
65 | On success, the second call to | ||
66 | .Fn SSL_shutdown | ||
67 | will return 1. | ||
68 | .Pp | ||
69 | If the peer already sent the | ||
70 | .Dq close notify | ||
71 | alert and it was already processed implicitly inside another function | ||
72 | .Pq Xr SSL_read 3 , | ||
73 | the | ||
74 | .Dv SSL_RECEIVED_SHUTDOWN | ||
75 | flag is set. | ||
76 | .Fn SSL_shutdown | ||
77 | will send the | ||
78 | .Dq close notify | ||
79 | alert, set the | ||
80 | .Dv SSL_SENT_SHUTDOWN | ||
81 | flag and will immediately return with 1. | ||
82 | Whether | ||
83 | .Dv SSL_RECEIVED_SHUTDOWN | ||
84 | is already set can be checked using the | ||
85 | .Fn SSL_get_shutdown | ||
86 | (see also the | ||
87 | .Xr SSL_set_shutdown 3 | ||
88 | call). | ||
89 | .Pp | ||
90 | It is therefore recommended to check the return value of | ||
91 | .Fn SSL_shutdown | ||
92 | and call | ||
93 | .Fn SSL_shutdown | ||
94 | again, if the bidirectional shutdown is not yet complete (return value of the | ||
95 | first call is 0). | ||
96 | As the shutdown is not specially handled in the SSLv2 protocol, | ||
97 | .Fn SSL_shutdown | ||
98 | will succeed on the first call. | ||
99 | .Pp | ||
100 | The behaviour of | ||
101 | .Fn SSL_shutdown | ||
102 | additionally depends on the underlying | ||
103 | .Vt BIO . | ||
104 | .Pp | ||
105 | If the underlying | ||
106 | .Vt BIO | ||
107 | is | ||
108 | .Em blocking , | ||
109 | .Fn SSL_shutdown | ||
110 | will only return once the | ||
111 | handshake step has been finished or an error occurred. | ||
112 | .Pp | ||
113 | If the underlying | ||
114 | .Vt BIO | ||
115 | is | ||
116 | .Em non-blocking , | ||
117 | .Fn SSL_shutdown | ||
118 | will also return when the underlying | ||
119 | .Vt BIO | ||
120 | could not satisfy the needs of | ||
121 | .Fn SSL_shutdown | ||
122 | to continue the handshake. | ||
123 | In this case a call to | ||
124 | .Xr SSL_get_error 3 | ||
125 | with the | ||
126 | return value of | ||
127 | .Fn SSL_shutdown | ||
128 | will yield | ||
129 | .Dv SSL_ERROR_WANT_READ | ||
130 | or | ||
131 | .Dv SSL_ERROR_WANT_WRITE . | ||
132 | The calling process then must repeat the call after taking appropriate action | ||
133 | to satisfy the needs of | ||
134 | .Fn SSL_shutdown . | ||
135 | The action depends on the underlying | ||
136 | .Vt BIO . | ||
137 | When using a non-blocking socket, nothing is to be done, but | ||
138 | .Xr select 2 | ||
139 | can be used to check for the required condition. | ||
140 | When using a buffering | ||
141 | .Vt BIO , | ||
142 | like a | ||
143 | .Vt BIO | ||
144 | pair, data must be written into or retrieved out of the | ||
145 | .Vt BIO | ||
146 | before being able to continue. | ||
147 | .Pp | ||
148 | .Fn SSL_shutdown | ||
149 | can be modified to only set the connection to | ||
150 | .Dq shutdown | ||
151 | state but not actually send the | ||
152 | .Dq close notify | ||
153 | alert messages; see | ||
154 | .Xr SSL_CTX_set_quiet_shutdown 3 . | ||
155 | When | ||
156 | .Dq quiet shutdown | ||
157 | is enabled, | ||
158 | .Fn SSL_shutdown | ||
159 | will always succeed and return 1. | ||
160 | .Sh RETURN VALUES | ||
161 | The following return values can occur: | ||
162 | .Bl -tag -width Ds | ||
163 | .It 0 | ||
164 | The shutdown is not yet finished. | ||
165 | Call | ||
166 | .Fn SSL_shutdown | ||
167 | for a second time, if a bidirectional shutdown shall be performed. | ||
168 | The output of | ||
169 | .Xr SSL_get_error 3 | ||
170 | may be misleading, as an erroneous | ||
171 | .Dv SSL_ERROR_SYSCALL | ||
172 | may be flagged even though no error occurred. | ||
173 | .It 1 | ||
174 | The shutdown was successfully completed. | ||
175 | The | ||
176 | .Dq close notify | ||
177 | alert was sent and the peer's | ||
178 | .Dq close notify | ||
179 | alert was received. | ||
180 | .It \(mi1 | ||
181 | The shutdown was not successful because a fatal error occurred either | ||
182 | at the protocol level or a connection failure occurred. | ||
183 | It can also occur if action is need to continue the operation for non-blocking | ||
184 | .Vt BIO Ns | ||
185 | s. | ||
186 | Call | ||
187 | .Xr SSL_get_error 3 | ||
188 | with the return value | ||
189 | .Fa ret | ||
190 | to find out the reason. | ||
191 | .El | ||
192 | .Sh SEE ALSO | ||
193 | .Xr bio 3 , | ||
194 | .Xr ssl 3 , | ||
195 | .Xr SSL_accept 3 , | ||
196 | .Xr SSL_clear 3 , | ||
197 | .Xr SSL_connect 3 , | ||
198 | .Xr SSL_CTX_set_quiet_shutdown 3 , | ||
199 | .Xr SSL_free 3 , | ||
200 | .Xr SSL_get_error 3 , | ||
201 | .Xr SSL_set_shutdown 3 | ||