1SSL_CTX_SET_MSG_CALLBACK(3)         OpenSSL        SSL_CTX_SET_MSG_CALLBACK(3)
2
3
4

NAME

6       SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg,
7       SSL_set_msg_callback, SSL_set_msg_callback_arg - install callback for
8       observing protocol messages
9

SYNOPSIS

11        #include <openssl/ssl.h>
12
13        void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
14                                      void (*cb)(int write_p, int version,
15                                                 int content_type, const void *buf,
16                                                 size_t len, SSL *ssl, void *arg));
17        void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
18
19        void SSL_set_msg_callback(SSL *ssl,
20                                  void (*cb)(int write_p, int version,
21                                             int content_type, const void *buf,
22                                             size_t len, SSL *ssl, void *arg));
23        void SSL_set_msg_callback_arg(SSL *ssl, void *arg);
24

DESCRIPTION

26       SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to
27       define a message callback function cb for observing all SSL/TLS
28       protocol messages (such as handshake messages) that are received or
29       sent, as well as other events that occur during processing.
30       SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg() can be
31       used to set argument arg to the callback function, which is available
32       for arbitrary application use.
33
34       SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify
35       default settings that will be copied to new SSL objects by SSL_new(3).
36       SSL_set_msg_callback() and SSL_set_msg_callback_arg() modify the actual
37       settings of an SSL object. Using a NULL pointer for cb disables the
38       message callback.
39
40       When cb is called by the SSL/TLS library the function arguments have
41       the following meaning:
42
43       write_p
44           This flag is 0 when a protocol message has been received and 1 when
45           a protocol message has been sent.
46
47       version
48           The protocol version according to which the protocol message is
49           interpreted by the library such as TLS1_3_VERSION, TLS1_2_VERSION
50           etc.  This is set to 0 for the SSL3_RT_HEADER pseudo content type
51           (see NOTES below).
52
53       content_type
54           This is one of the content type values defined in the protocol
55           specification (SSL3_RT_CHANGE_CIPHER_SPEC, SSL3_RT_ALERT,
56           SSL3_RT_HANDSHAKE; but never SSL3_RT_APPLICATION_DATA because the
57           callback will only be called for protocol messages). Alternatively
58           it may be a "pseudo" content type. These pseudo content types are
59           used to signal some other event in the processing of data (see
60           NOTES below).
61
62       buf, len
63           buf points to a buffer containing the protocol message or other
64           data (in the case of pseudo content types), which consists of len
65           bytes. The buffer is no longer valid after the callback function
66           has returned.
67
68       ssl The SSL object that received or sent the message.
69
70       arg The user-defined argument optionally defined by
71           SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg().
72

NOTES

74       Protocol messages are passed to the callback function after decryption
75       and fragment collection where applicable. (Thus record boundaries are
76       not visible.)
77
78       If processing a received protocol message results in an error, the
79       callback function may not be called.  For example, the callback
80       function will never see messages that are considered too large to be
81       processed.
82
83       Due to automatic protocol version negotiation, version is not
84       necessarily the protocol version used by the sender of the message: If
85       a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
86       version will be SSL3_VERSION.
87
88       Pseudo content type values may be sent at various points during the
89       processing of data. The following pseudo content types are currently
90       defined:
91
92       SSL3_RT_HEADER
93           Used when a record is sent or received. The buf contains the record
94           header bytes only.
95
96       SSL3_RT_INNER_CONTENT_TYPE
97           Used when an encrypted TLSv1.3 record is sent or received. In
98           encrypted TLSv1.3 records the content type in the record header is
99           always SSL3_RT_APPLICATION_DATA. The real content type for the
100           record is contained in an "inner" content type. buf contains the
101           encoded "inner" content type byte.
102

RETURN VALUES

104       SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(),
105       SSL_set_msg_callback() and SSL_set_msg_callback_arg() do not return
106       values.
107

SEE ALSO

109       ssl(7), SSL_new(3)
110

HISTORY

112       The pseudo content type SSL3_RT_INNER_CONTENT_TYPE was added in OpenSSL
113       1.1.1.
114
116       Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
117
118       Licensed under the OpenSSL license (the "License").  You may not use
119       this file except in compliance with the License.  You can obtain a copy
120       in the file LICENSE in the source distribution or at
121       <https://www.openssl.org/source/license.html>.
122
123
124
1251.1.1                             2018-09-11       SSL_CTX_SET_MSG_CALLBACK(3)
Impressum