SSL_get_error(3) OpenSSL SSL_get_error(3) NNAAMMEE SSL_get_error - obtain result code for TLS/SSL I/O operation SSYYNNOOPPSSIISS #include int SSL_get_error(const SSL *ssl, int ret); DDEESSCCRRIIPPTTIIOONN _S_S_L___g_e_t___e_r_r_o_r_(_) returns a result code (suitable for the C "switch" statement) for a preceding call to _S_S_L___c_o_n_n_e_c_t_(_), _S_S_L___a_c_c_e_p_t_(_), _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_), _S_S_L___r_e_a_d_(_), _S_S_L___p_e_e_k_(_), or _S_S_L___w_r_i_t_e_(_) on ssssll. The value returned by that TLS/SSL I/O function must be passed to _S_S_L___g_e_t___e_r_r_o_r_(_) in parameter rreett. In addition to ssssll and rreett, _S_S_L___g_e_t___e_r_r_o_r_(_) inspects the current thread's OpenSSL error queue. Thus, _S_S_L___g_e_t___e_r_r_o_r_(_) must be used in the same thread that performed the TLS/SSL I/O operation, and no other OpenSSL function calls should appear in between. The current thread's error queue must be empty before the TLS/SSL I/O operation is attempted, or _S_S_L___g_e_t___e_r_r_o_r_(_) will not work reliably. RREETTUURRNN VVAALLUUEESS The following return values can currently occur: SSL_ERROR_NONE The TLS/SSL I/O operation completed. This result code is returned if and only if rreett >> 00. SSL_ERROR_ZERO_RETURN The TLS/SSL connection has been closed. If the protocol version is SSL 3.0 or TLS 1.0, this result code is returned only if a closure alert has occurred in the protocol, i.e. if the connection has been closed cleanly. Note that in this case SSSSLL__EERRRROORR__ZZEERROO__RREETTUURRNN does not necessarily indicate that the underlying transport has been closed. SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE The operation did not complete; the same TLS/SSL I/O function should be called again later. If, by then, the underlying BBIIOO has data available for reading (if the result code is SSSSLL__EERRRROORR__WWAANNTT__RREEAADD) or allows writing data (SSSSLL__EERRRROORR__WWAANNTT__WWRRIITTEE), then some TLS/SSL protocol progress will take place, i.e. at least part of an TLS/SSL record will be read or written. Note that the retry may again lead to a SSSSLL__EERRRROORR__WWAANNTT__RREEAADD or SSSSLL__EERRRROORR__WWAANNTT__WWRRIITTEE condition. There is no fixed upper limit for the number of iterations that may be necessary until progress becomes visible at application protocol level. For socket BBIIOOs (e.g. when _S_S_L___s_e_t___f_d_(_) was used), _s_e_l_e_c_t_(_) or _p_o_l_l_(_) on the underlying socket can be used to find out when the TLS/SSL I/O function should be retried. Caveat: Any TLS/SSL I/O function can lead to either of SSSSLL__EERRRROORR__WWAANNTT__RREEAADD and SSSSLL__EERRRROORR__WWAANNTT__WWRRIITTEE. In particular, _S_S_L___r_e_a_d_(_) or _S_S_L___p_e_e_k_(_) may want to write data and _S_S_L___w_r_i_t_e_(_) may want to read data. This is mainly because TLS/SSL handshakes may occur at any time during the protocol (initiated by either the client or the server); _S_S_L___r_e_a_d_(_), _S_S_L___p_e_e_k_(_), and _S_S_L___w_r_i_t_e_(_) will handle any pending handshakes. SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT The operation did not complete; the same TLS/SSL I/O function should be called again later. The underlying BIO was not connected yet to the peer and the call would block in _c_o_n_n_e_c_t_(_)/_a_c_c_e_p_t_(_). The SSL function should be called again when the connection is estab- lished. These messages can only appear with a _B_I_O___s___c_o_n_n_e_c_t_(_) or _B_I_O___s___a_c_c_e_p_t_(_) BIO, respectively. In order to find out, when the connection has been successfully established, on many platforms _s_e_l_e_c_t_(_) or _p_o_l_l_(_) for writing on the socket file descriptor can be used. SSL_ERROR_WANT_X509_LOOKUP The operation did not complete because an application callback set by _S_S_L___C_T_X___s_e_t___c_l_i_e_n_t___c_e_r_t___c_b_(_) has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application. SSL_ERROR_SYSCALL Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. _E_R_R___g_e_t___e_r_r_o_r_(_) returns 0), rreett can be used to find out more about the error: If rreett ==== 00, an EOF was observed that violates the pro- tocol. If rreett ==== --11, the underlying BBIIOO reported an I/O error (for socket I/O on Unix systems, consult eerrrrnnoo for details). SSL_ERROR_SSL A failure in the SSL library occurred, usually a protocol error. The OpenSSL error queue contains more information on the error. SSEEEE AALLSSOO _s_s_l(3), _e_r_r(3) HHIISSTTOORRYY _S_S_L___g_e_t___e_r_r_o_r_(_) was added in SSLeay 0.8. 1.0.1u 2016-09-22 SSL_get_error(3)