SSL_CTX_set_info_callback(3) OpenSSL SSL_CTX_set_info_callback(3) NNAAMMEE SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback - handle information call- back for SSL connections SSYYNNOOPPSSIISS #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))(); DDEESSCCRRIIPPTTIIOONN _S_S_L___C_T_X___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 SSL objects created from ccttxx dur- ing connection setup and use. The setting for ccttxx is overridden from the setting for a specific SSL object, if specified. When ccaallllbbaacckk is NULL, not callback function is used. _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 informa- tion callback function for ssssll. NNOOTTEESS When setting up a connection and during use, it is possible to obtain state information from the SSL/TLS engine. When set, an information callback function is called whenever the state changes, an alert appears, or an error occurs. 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 condi- tion 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: SSL_CB_LOOP Callback has been called to indicate state change inside a loop. SSL_CB_EXIT Callback has been called to indicate error exit of a handshake function. (May be soft error with retry option for non-blocking setups.) SSL_CB_READ Callback has been called during read operation. SSL_CB_WRITE Callback has been called during write operation. SSL_CB_ALERT Callback has been called due to an alert being sent or received. SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) SSL_CB_HANDSHAKE_START Callback has been called because a new handshake is started. SSL_CB_HANDSHAKE_DONE 0x20 Callback has been called because a handshake is finished. 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. RREETTUURRNN VVAALLUUEESS _S_S_L___s_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) does not provide diagnostic information. _S_S_L___g_e_t___i_n_f_o___c_a_l_l_b_a_c_k_(_) returns the current setting. EEXXAAMMPPLLEESS The following example callback function prints state strings, informa- tion about alerts being handled and error messages to the bbiioo__eerrrr BIO. 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)); } } } SSEEEE AALLSSOO _s_s_l(3), _S_S_L___s_t_a_t_e___s_t_r_i_n_g(3), _S_S_L___a_l_e_r_t___t_y_p_e___s_t_r_i_n_g(3) 1.0.2u 2019-12-20 SSL_CTX_set_info_callback(3)