1SSL_GET_ERROR(3ossl)                OpenSSL               SSL_GET_ERROR(3ossl)
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

NOTES

29       Some TLS implementations do not send a close_notify alert on shutdown.
30
31       On an unexpected EOF, versions before OpenSSL 3.0 returned
32       SSL_ERROR_SYSCALL, nothing was added to the error stack, and errno was
33       0.  Since OpenSSL 3.0 the returned error is SSL_ERROR_SSL with a
34       meaningful error on the error stack.
35

RETURN VALUES

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

SEE ALSO

162       ssl(7)
163

HISTORY

165       The SSL_ERROR_WANT_ASYNC error code was added in OpenSSL 1.1.0.  The
166       SSL_ERROR_WANT_CLIENT_HELLO_CB error code was added in OpenSSL 1.1.1.
167
169       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
170
171       Licensed under the Apache License 2.0 (the "License").  You may not use
172       this file except in compliance with the License.  You can obtain a copy
173       in the file LICENSE in the source distribution or at
174       <https://www.openssl.org/source/license.html>.
175
176
177
1783.0.5                             2022-07-05              SSL_GET_ERROR(3ossl)
Impressum