1=pod 2 3=head1 NAME 4 5SSL_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 6 7=head1 SYNOPSIS 8 9 #include <openssl/ssl.h> 10 11 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)); 12 void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); 13 14 void SSL_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)); 15 void SSL_set_msg_callback_arg(SSL_CTX *ctx, void *arg); 16 17=head1 DESCRIPTION 18 19SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to 20define a message callback function I<cb> for observing all SSL/TLS 21protocol messages (such as handshake messages) that are received or 22sent. SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg() 23can be used to set argument I<arg> to the callback function, which is 24available for arbitrary application use. 25 26SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify 27default settings that will be copied to new B<SSL> objects by 28L<SSL_new(3)|SSL_new(3)>. SSL_set_msg_callback() and 29SSL_set_msg_callback_arg() modify the actual settings of an B<SSL> 30object. Using a B<0> pointer for I<cb> disables the message callback. 31 32When I<cb> is called by the SSL/TLS library for a protocol message, 33the function arguments have the following meaning: 34 35=over 4 36 37=item I<write_p> 38 39This flag is B<0> when a protocol message has been received and B<1> 40when a protocol message has been sent. 41 42=item I<version> 43 44The protocol version according to which the protocol message is 45interpreted by the library. Currently, this is one of 46B<SSL2_VERSION>, B<SSL3_VERSION> and B<TLS1_VERSION> (for SSL 2.0, SSL 473.0 and TLS 1.0, respectively). 48 49=item I<content_type> 50 51In the case of SSL 2.0, this is always B<0>. In the case of SSL 3.0 52or TLS 1.0, this is one of the B<ContentType> values defined in the 53protocol specification (B<change_cipher_spec(20)>, B<alert(21)>, 54B<handshake(22)>; but never B<application_data(23)> because the 55callback will only be called for protocol messages). 56 57=item I<buf>, I<len> 58 59I<buf> points to a buffer containing the protocol message, which 60consists of I<len> bytes. The buffer is no longer valid after the 61callback function has returned. 62 63=item I<ssl> 64 65The B<SSL> object that received or sent the message. 66 67=item I<arg> 68 69The user-defined argument optionally defined by 70SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg(). 71 72=back 73 74=head1 NOTES 75 76Protocol messages are passed to the callback function after decryption 77and fragment collection where applicable. (Thus record boundaries are 78not visible.) 79 80If processing a received protocol message results in an error, 81the callback function may not be called. For example, the callback 82function will never see messages that are considered too large to be 83processed. 84 85Due to automatic protocol version negotiation, I<version> is not 86necessarily the protocol version used by the sender of the message: If 87a TLS 1.0 ClientHello message is received by an SSL 3.0-only server, 88I<version> will be B<SSL3_VERSION>. 89 90=head1 SEE ALSO 91 92L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)> 93 94=head1 HISTORY 95 96SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(), 97SSL_set_msg_callback() and SSL_get_msg_callback_arg() were added in OpenSSL 0.9.7. 98 99=cut 100