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