#include
void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)()); void (*SSL_CTX_get_info_callback(const SSL_CTX *ctx))();
void SSL_set_info_callback(SSL *ssl, void (*callback)()); void (*SSL_get_info_callback(const SSL *ssl))();
_S_S_L___s_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) sets the ccaallllbbaacckk function, that can be used to obtain state information for ssssll during connection setup and use. When ccaallllbbaacckk is NULL, the callback setting currently valid for ccttxx is used.
_S_S_L___C_T_X___g_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) returns a pointer to the currently set information callback function for ccttxx.
_S_S_L___g_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) returns a pointer to the currently set information callback function for ssssll.
The callback function is called as ccaallllbbaacckk((SSSSLL **ssssll,, iinntt wwhheerree,, iinntt rreett)). The wwhheerree argument specifies information about where (in which context) the callback function was called. If rreett is 0, an error condition occurred. If an alert is handled, SSL_CB_ALERT is set and rreett specifies the alert information.
wwhheerree is a bitmask made up of the following bits:
The current state information can be obtained using the _S_S_L___s_t_a_t_e___s_t_r_i_n_g(3) family of functions.
The rreett information can be evaluated using the _S_S_L___a_l_e_r_t___t_y_p_e___s_t_r_i_n_g(3) family of functions.
_S_S_L___g_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) returns the current setting.
void apps_ssl_info_callback(SSL *s, int where, int ret) { const char *str; int w;
w=where& ~SSL_ST_MASK;
if (w & SSL_ST_CONNECT) str="SSL_connect"; else if (w & SSL_ST_ACCEPT) str="SSL_accept"; else str="undefined";
if (where & SSL_CB_LOOP) { BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s)); } else if (where & SSL_CB_ALERT) { str=(where & SSL_CB_READ)?"read":"write"; BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n", str, SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret)); } else if (where & SSL_CB_EXIT) { if (ret == 0) BIO_printf(bio_err,"%s:failed in %s\n", str,SSL_state_string_long(s)); else if (ret < 0) { BIO_printf(bio_err,"%s:error in %s\n", str,SSL_state_string_long(s)); } } }