summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_read.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_read.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_read.3')
-rw-r--r--src/lib/libssl/doc/SSL_read.3190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_read.3 b/src/lib/libssl/doc/SSL_read.3
new file mode 100644
index 0000000000..aed39c300f
--- /dev/null
+++ b/src/lib/libssl/doc/SSL_read.3
@@ -0,0 +1,190 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt SSL_READ 3
3.Os
4.Sh NAME
5.Nm SSL_read
6.Nd read bytes from a TLS/SSL connection.
7.Sh SYNOPSIS
8.In openssl/ssl.h
9.Ft int
10.Fn SSL_read "SSL *ssl" "void *buf" "int num"
11.Sh DESCRIPTION
12.Fn SSL_read
13tries to read
14.Fa num
15bytes from the specified
16.Fa ssl
17into the buffer
18.Fa buf .
19.Sh NOTES
20If necessary,
21.Fn SSL_read
22will negotiate a TLS/SSL session, if not already explicitly performed by
23.Xr SSL_connect 3
24or
25.Xr SSL_accept 3 .
26If the peer requests a re-negotiation,
27it will be performed transparently during the
28.Fn SSL_read
29operation.
30The behaviour of
31.Fn SSL_read
32depends on the underlying
33.Vt BIO .
34.Pp
35For the transparent negotiation to succeed, the
36.Fa ssl
37must have been initialized to client or server mode.
38This is being done by calling
39.Xr SSL_set_connect_state 3
40or
41.Xr SSL_set_accept_state 3
42before the first call to
43.Fn SSL_read
44or
45.Xr SSL_write 3 .
46.Pp
47.Fn SSL_read
48works based on the SSL/TLS records.
49The data are received in records (with a maximum record size of 16kB for
50SSLv3/TLSv1).
51Only after a record has been completely received can it be processed
52(decrypted and checked for integrity).
53Therefore data not retrieved at the last call of
54.Fn SSL_read
55can still be buffered inside the SSL layer and will be retrieved on the next
56call to
57.Fn SSL_read .
58If
59.Fa num
60is higher than the number of bytes buffered,
61.Fn SSL_read
62will return with the bytes buffered.
63If no more bytes are in the buffer,
64.Fn SSL_read
65will trigger the processing of the next record.
66Only when the record has been received and processed completely will
67.Fn SSL_read
68return reporting success.
69At most the contents of the record will be returned.
70As the size of an SSL/TLS record may exceed the maximum packet size of the
71underlying transport (e.g., TCP), it may be necessary to read several packets
72from the transport layer before the record is complete and
73.Fn SSL_read
74can succeed.
75.Pp
76If the underlying
77.Vt BIO
78is
79.Em blocking ,
80.Fn SSL_read
81will only return once the read operation has been finished or an error
82has occurred, except when a renegotiation take place, in which case a
83.Dv SSL_ERROR_WANT_READ
84may occur.
85This behavior can be controlled with the
86.Dv SSL_MODE_AUTO_RETRY
87flag of the
88.Xr SSL_CTX_set_mode 3
89call.
90.Pp
91If the underlying
92.Vt BIO
93is
94.Em non-blocking ,
95.Fn SSL_read
96will also return when the underlying
97.Vt BIO
98could not satisfy the needs of
99.Fn SSL_read
100to continue the operation.
101In this case a call to
102.Xr SSL_get_error 3
103with the return value of
104.Fn SSL_read
105will yield
106.Dv SSL_ERROR_WANT_READ
107or
108.Dv SSL_ERROR_WANT_WRITE .
109As at any time a re-negotiation is possible, a call to
110.Fn SSL_read
111can also cause write operations!
112The calling process then must repeat the call after taking appropriate action
113to satisfy the needs of
114.Fn SSL_read .
115The action depends on the underlying
116.Vt BIO .
117When using a non-blocking socket, nothing is to be done, but
118.Xr select 2
119can be used to check for the required condition.
120When using a buffering
121.Vt BIO ,
122like a
123.Vt BIO
124pair, data must be written into or retrieved out of the
125.Vt BIO
126before being able to continue.
127.Pp
128.Xr SSL_pending 3
129can be used to find out whether there are buffered bytes available for
130immediate retrieval.
131In this case
132.Fn SSL_read
133can be called without blocking or actually receiving new data from the
134underlying socket.
135.Sh WARNING
136When an
137.Fn SSL_read
138operation has to be repeated because of
139.Dv SSL_ERROR_WANT_READ
140or
141.Dv SSL_ERROR_WANT_WRITE ,
142it must be repeated with the same arguments.
143.Sh RETURN VALUES
144The following return values can occur:
145.Bl -tag -width Ds
146.It >0
147The read operation was successful; the return value is the number of bytes
148actually read from the TLS/SSL connection.
149.It 0
150The read operation was not successful.
151The reason may either be a clean shutdown due to a
152.Dq close notify
153alert sent by the peer (in which case the
154.Dv SSL_RECEIVED_SHUTDOWN
155flag in the ssl shutdown state is set (see
156.Xr SSL_shutdown 3
157and
158.Xr SSL_set_shutdown 3 ) .
159It is also possible that the peer simply shut down the underlying transport and
160the shutdown is incomplete.
161Call
162.Fn SSL_get_error
163with the return value to find out whether an error occurred or the connection
164was shut down cleanly
165.Pq Dv SSL_ERROR_ZERO_RETURN .
166.Pp
167SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only
168be detected whether the underlying connection was closed.
169It cannot be checked whether the closure was initiated by the peer or by
170something else.
171.It <0
172The read operation was not successful, because either an error occurred or
173action must be taken by the calling process.
174Call
175.Fn SSL_get_error
176with the return value to find out the reason.
177.El
178.Sh SEE ALSO
179.Xr bio 3 ,
180.Xr ssl 3 ,
181.Xr SSL_accept 3 ,
182.Xr SSL_connect 3 ,
183.Xr SSL_CTX_new 3 ,
184.Xr SSL_CTX_set_mode 3 ,
185.Xr SSL_get_error 3 ,
186.Xr SSL_pending 3 ,
187.Xr SSL_set_connect_state 3 ,
188.Xr SSL_set_shutdown 3 ,
189.Xr SSL_shutdown 3 ,
190.Xr SSL_write 3