SSL_CTX_set_msg_callback.pod 3.4 KB

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