SSL_do_handshake 3 2002-07-30 0.9.9-dev OpenSSL
NAME
SSL_do_handshake - perform a TLS/SSL handshake
LIBRARY
libcrypto, -lcrypto
SYNOPSIS
#include
int SSL_do_handshake(SSL *ssl);
DESCRIPTION
_S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) will wait for a SSL/TLS handshake to take place. If the
connection is in client mode, the handshake will be started. The handshake
routines may have to be explicitly set in advance using either
_S_S_L___s_e_t___c_o_n_n_e_c_t___s_t_a_t_e(3) or
_S_S_L___s_e_t___a_c_c_e_p_t___s_t_a_t_e(3).
NOTES
The behaviour of _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) depends on the underlying BIO.
If the underlying BIO is bblloocckkiinngg, _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) will only return
once the handshake has been finished or an error occurred, except for SGC
(Server Gated Cryptography). For SGC, _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) may return with -1,
but _S_S_L___g_e_t___e_r_r_o_r_(_) will yield SSSSLL__EERRRROORR__WWAANNTT__RREEAADD//WWRRIITTEE and
_S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) should be called again.
If the underlying BIO is nnoonn--bblloocckkiinngg, _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) will also return
when the underlying BIO could not satisfy the needs of _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_)
to continue the handshake. In this case a call to _S_S_L___g_e_t___e_r_r_o_r_(_) with the
return value of _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_) will yield SSSSLL__EERRRROORR__WWAANNTT__RREEAADD or
SSSSLL__EERRRROORR__WWAANNTT__WWRRIITTEE. The calling process then must repeat the call after
taking appropriate action to satisfy the needs of _S_S_L___d_o___h_a_n_d_s_h_a_k_e_(_).
The action depends on the underlying BIO. When using a non-blocking socket,
nothing is to be done, but _s_e_l_e_c_t_(_) can be used to check for the required
condition. When using a buffering BIO, like a BIO pair, data must be written
into or retrieved out of the BIO before being able to continue.
RETURN VALUES
The following return values can occur:
-
1
The TLS/SSL handshake was successfully completed, a TLS/SSL connection has been
-
established.
-
0
The TLS/SSL handshake was not successful but was shut down controlled and
-
by the specifications of the TLS/SSL protocol. Call _S_S_L___g_e_t___e_r_r_o_r_(_) with the
return value rreett to find out the reason.
-
<0
The TLS/SSL handshake was not successful because a fatal error occurred either
-
at the protocol level or a connection failure occurred. The shutdown was
not clean. It can also occur of action is need to continue the operation
for non-blocking BIOs. Call _S_S_L___g_e_t___e_r_r_o_r_(_) with the return value rreett
to find out the reason.
SEE ALSO
_S_S_L___g_e_t___e_r_r_o_r(3), _S_S_L___c_o_n_n_e_c_t(3),
_S_S_L___a_c_c_e_p_t(3), _s_s_l(3), _o_p_e_n_s_s_l___b_i_o(3),
_S_S_L___s_e_t___c_o_n_n_e_c_t___s_t_a_t_e(3)