SSL_CTX_set_msg_callback(3) OpenSSL SSL_CTX_set_msg_callback(3) NNAAMMEE SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg, SSL_set_msg_callback, SSL_get_msg_callback_arg - install callback for observing protocol messages SSYYNNOOPPSSIISS #include void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); void SSL_set_msg_callback_arg(SSL *ssl, void *arg); DDEESSCCRRIIPPTTIIOONN _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_) or _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_) can be used to define a message callback function _c_b for observing all SSL/TLS proto- col messages (such as handshake messages) that are received or sent. _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) and _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) can be used to set argument _a_r_g to the callback function, which is available for arbitrary application use. _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_) and _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) specify default settings that will be copied to new SSSSLL objects by _S_S_L___n_e_w(3). _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_) and _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) modify the actual settings of an SSSSLL object. Using a 00 pointer for _c_b disables the mes- sage callback. When _c_b is called by the SSL/TLS library for a protocol message, the function arguments have the following meaning: _w_r_i_t_e___p This flag is 00 when a protocol message has been received and 11 when a protocol message has been sent. _v_e_r_s_i_o_n The protocol version according to which the protocol message is interpreted by the library. Currently, this is one of SSSSLL22__VVEERRSSIIOONN, SSSSLL33__VVEERRSSIIOONN and TTLLSS11__VVEERRSSIIOONN (for SSL 2.0, SSL 3.0 and TLS 1.0, respectively). _c_o_n_t_e_n_t___t_y_p_e In the case of SSL 2.0, this is always 00. In the case of SSL 3.0 or TLS 1.0, this is one of the CCoonntteennttTTyyppee values defined in the protocol specification (cchhaannggee__cciipphheerr__ssppeecc((2200)), aalleerrtt((2211)), hhaanndd-- sshhaakkee((2222)); but never aapppplliiccaattiioonn__ddaattaa((2233)) because the callback will only be called for protocol messages). _b_u_f, _l_e_n _b_u_f points to a buffer containing the protocol message, which con- sists of _l_e_n bytes. The buffer is no longer valid after the call- back function has returned. _s_s_l The SSSSLL object that received or sent the message. _a_r_g The user-defined argument optionally defined by _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) or _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_). NNOOTTEESS Protocol messages are passed to the callback function after decryption and fragment collection where applicable. (Thus record boundaries are not visible.) If processing a received protocol message results in an error, the callback function may not be called. For example, the callback func- tion will never see messages that are considered too large to be pro- cessed. Due to automatic protocol version negotiation, _v_e_r_s_i_o_n is not necessar- ily the protocol version used by the sender of the message: If a TLS 1.0 ClientHello message is received by an SSL 3.0-only server, _v_e_r_s_i_o_n will be SSSSLL33__VVEERRSSIIOONN. SSEEEE AALLSSOO _s_s_l(3), _S_S_L___n_e_w(3) HHIISSTTOORRYY _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_), _S_S_L___C_T_X___s_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_), _S_S_L___s_e_t___m_s_g___c_a_l_l_b_a_c_k_(_) and _S_S_L___g_e_t___m_s_g___c_a_l_l_b_a_c_k___a_r_g_(_) were added in OpenSSL 0.9.7. 1.0.2u 2019-12-20 SSL_CTX_set_msg_callback(3)