1SSL_GET_ERROR(3)                    OpenSSL                   SSL_GET_ERROR(3)
2
3
4

NAME

6       SSL_get_error - obtain result code for TLS/SSL I/O operation
7

SYNOPSIS

9        #include <openssl/ssl.h>
10
11        int SSL_get_error(const SSL *ssl, int ret);
12

DESCRIPTION

14       SSL_get_error() returns a result code (suitable for the C "switch"
15       statement) for a preceding call to SSL_connect(), SSL_accept(),
16       SSL_do_handshake(), SSL_read_ex(), SSL_read(), SSL_peek_ex(),
17       SSL_peek(), SSL_shutdown(), SSL_write_ex() or SSL_write() on ssl.  The
18       value returned by that TLS/SSL I/O function must be passed to
19       SSL_get_error() in parameter ret.
20
21       In addition to ssl and ret, SSL_get_error() inspects the current
22       thread's OpenSSL error queue.  Thus, SSL_get_error() must be used in
23       the same thread that performed the TLS/SSL I/O operation, and no other
24       OpenSSL function calls should appear in between.  The current thread's
25       error queue must be empty before the TLS/SSL I/O operation is
26       attempted, or SSL_get_error() will not work reliably.
27

RETURN VALUES

29       The following return values can currently occur:
30
31       SSL_ERROR_NONE
32           The TLS/SSL I/O operation completed.  This result code is returned
33           if and only if ret > 0.
34
35       SSL_ERROR_ZERO_RETURN
36           The TLS/SSL peer has closed the connection for writing by sending
37           the close_notify alert.  No more data can be read.  Note that
38           SSL_ERROR_ZERO_RETURN does not necessarily indicate that the
39           underlying transport has been closed.
40
41       SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE
42           The operation did not complete and can be retried later.
43
44           SSL_ERROR_WANT_READ is returned when the last operation was a read
45           operation from a nonblocking BIO.  It means that not enough data
46           was available at this time to complete the operation.  If at a
47           later time the underlying BIO has data available for reading the
48           same function can be called again.
49
50           SSL_read() and SSL_read_ex() can also set SSL_ERROR_WANT_READ when
51           there is still unprocessed data available at either the SSL or the
52           BIO layer, even for a blocking BIO.  See SSL_read(3) for more
53           information.
54
55           SSL_ERROR_WANT_WRITE is returned when the last operation was a
56           write to a nonblocking BIO and it was unable to sent all data to
57           the BIO.  When the BIO is writable again, the same function can be
58           called again.
59
60           Note that the retry may again lead to an SSL_ERROR_WANT_READ or
61           SSL_ERROR_WANT_WRITE condition.  There is no fixed upper limit for
62           the number of iterations that may be necessary until progress
63           becomes visible at application protocol level.
64
65           It is safe to call SSL_read() or SSL_read_ex() when more data is
66           available even when the call that set this error was an SSL_write()
67           or SSL_write_ex().  However, if the call was an SSL_write() or
68           SSL_write_ex(), it should be called again to continue sending the
69           application data.
70
71           For socket BIOs (e.g. when SSL_set_fd() was used), select() or
72           poll() on the underlying socket can be used to find out when the
73           TLS/SSL I/O function should be retried.
74
75           Caveat: Any TLS/SSL I/O function can lead to either of
76           SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE.  In particular,
77           SSL_read_ex(), SSL_read(), SSL_peek_ex(), or SSL_peek() may want to
78           write data and SSL_write() or SSL_write_ex() may want to read data.
79           This is mainly because TLS/SSL handshakes may occur at any time
80           during the protocol (initiated by either the client or the server);
81           SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(),
82           SSL_write_ex(), and SSL_write() will handle any pending handshakes.
83
84       SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT
85           The operation did not complete; the same TLS/SSL I/O function
86           should be called again later. The underlying BIO was not connected
87           yet to the peer and the call would block in connect()/accept(). The
88           SSL function should be called again when the connection is
89           established. These messages can only appear with a BIO_s_connect()
90           or BIO_s_accept() BIO, respectively.  In order to find out, when
91           the connection has been successfully established, on many platforms
92           select() or poll() for writing on the socket file descriptor can be
93           used.
94
95       SSL_ERROR_WANT_X509_LOOKUP
96           The operation did not complete because an application callback set
97           by SSL_CTX_set_client_cert_cb() has asked to be called again.  The
98           TLS/SSL I/O function should be called again later.  Details depend
99           on the application.
100
101       SSL_ERROR_WANT_ASYNC
102           The operation did not complete because an asynchronous engine is
103           still processing data. This will only occur if the mode has been
104           set to SSL_MODE_ASYNC using SSL_CTX_set_mode(3) or SSL_set_mode(3)
105           and an asynchronous capable engine is being used. An application
106           can determine whether the engine has completed its processing using
107           select() or poll() on the asynchronous wait file descriptor. This
108           file descriptor is available by calling SSL_get_all_async_fds(3) or
109           SSL_get_changed_async_fds(3). The TLS/SSL I/O function should be
110           called again later. The function must be called from the same
111           thread that the original call was made from.
112
113       SSL_ERROR_WANT_ASYNC_JOB
114           The asynchronous job could not be started because there were no
115           async jobs available in the pool (see ASYNC_init_thread(3)). This
116           will only occur if the mode has been set to SSL_MODE_ASYNC using
117           SSL_CTX_set_mode(3) or SSL_set_mode(3) and a maximum limit has been
118           set on the async job pool through a call to ASYNC_init_thread(3).
119           The application should retry the operation after a currently
120           executing asynchronous operation for the current thread has
121           completed.
122
123       SSL_ERROR_WANT_CLIENT_HELLO_CB
124           The operation did not complete because an application callback set
125           by SSL_CTX_set_client_hello_cb() has asked to be called again.  The
126           TLS/SSL I/O function should be called again later.  Details depend
127           on the application.
128
129       SSL_ERROR_SYSCALL
130           Some non-recoverable, fatal I/O error occurred. The OpenSSL error
131           queue may contain more information on the error. For socket I/O on
132           Unix systems, consult errno for details. If this error occurs then
133           no further I/O operations should be performed on the connection and
134           SSL_shutdown() must not be called.
135
136           This value can also be returned for other errors, check the error
137           queue for details.
138
139       SSL_ERROR_SSL
140           A non-recoverable, fatal error in the SSL library occurred, usually
141           a protocol error.  The OpenSSL error queue contains more
142           information on the error. If this error occurs then no further I/O
143           operations should be performed on the connection and SSL_shutdown()
144           must not be called.
145

BUGS

147       The SSL_ERROR_SYSCALL with errno value of 0 indicates unexpected EOF
148       from the peer. This will be properly reported as SSL_ERROR_SSL with
149       reason code SSL_R_UNEXPECTED_EOF_WHILE_READING in the OpenSSL 3.0
150       release because it is truly a TLS protocol error to terminate the
151       connection without a SSL_shutdown().
152
153       The issue is kept unfixed in OpenSSL 1.1.1 releases because many
154       applications which choose to ignore this protocol error depend on the
155       existing way of reporting the error.
156

SEE ALSO

158       ssl(7)
159

HISTORY

161       The SSL_ERROR_WANT_ASYNC error code was added in OpenSSL 1.1.0.  The
162       SSL_ERROR_WANT_CLIENT_HELLO_CB error code was added in OpenSSL 1.1.1.
163
165       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
166
167       Licensed under the OpenSSL license (the "License").  You may not use
168       this file except in compliance with the License.  You can obtain a copy
169       in the file LICENSE in the source distribution or at
170       <https://www.openssl.org/source/license.html>.
171
172
173
1741.1.1i                            2021-01-26                  SSL_GET_ERROR(3)
Impressum