Add -p (public only) flag to find-doc-nits
[openssl.git] / doc / man3 / SSL_CTX_set_msg_callback.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_set_msg_callback,
6 SSL_CTX_set_msg_callback_arg,
7 SSL_set_msg_callback,
8 SSL_set_msg_callback_arg
9 - install callback for observing protocol messages
10
11 =head1 SYNOPSIS
12
13  #include <openssl/ssl.h>
14
15  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));
16  void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
17
18  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));
19  void SSL_set_msg_callback_arg(SSL *ssl, void *arg);
20
21 =head1 DESCRIPTION
22
23 SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to
24 define a message callback function I<cb> for observing all SSL/TLS
25 protocol messages (such as handshake messages) that are received or
26 sent, as well as other events that occur during processing.
27 SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg()
28 can be used to set argument I<arg> to the callback function, which is
29 available for arbitrary application use.
30
31 SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify
32 default settings that will be copied to new B<SSL> objects by
33 L<SSL_new(3)>. SSL_set_msg_callback() and
34 SSL_set_msg_callback_arg() modify the actual settings of an B<SSL>
35 object. Using a B<NULL> pointer for I<cb> disables the message callback.
36
37 When I<cb> is called by the SSL/TLS library the function arguments have the
38 following meaning:
39
40 =over 4
41
42 =item I<write_p>
43
44 This flag is B<0> when a protocol message has been received and B<1>
45 when a protocol message has been sent.
46
47 =item I<version>
48
49 The protocol version according to which the protocol message is
50 interpreted by the library such as B<TLS1_3_VERSION>, B<TLS1_2_VERSION> etc.
51 This is set to 0 for the SSL3_RT_HEADER pseudo content type (see NOTES below).
52
53 =item I<content_type>
54
55 This is one of the content type values defined in the protocol specification
56 (B<SSL3_RT_CHANGE_CIPHER_SPEC>, B<SSL3_RT_ALERT>, B<SSL3_RT_HANDSHAKE>; but never
57 B<SSL3_RT_APPLICATION_DATA> because the callback will only be called for protocol
58 messages). Alternatively it may be a "pseudo" content type. These pseudo
59 content types are used to signal some other event in the processing of data (see
60 NOTES below).
61
62 =item I<buf>, I<len>
63
64 I<buf> points to a buffer containing the protocol message or other data (in the
65 case of pseudo content types), which consists of I<len> bytes. The buffer is no
66 longer valid after the callback function has returned.
67
68 =item I<ssl>
69
70 The B<SSL> object that received or sent the message.
71
72 =item I<arg>
73
74 The user-defined argument optionally defined by
75 SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg().
76
77 =back
78
79 =head1 NOTES
80
81 Protocol messages are passed to the callback function after decryption
82 and fragment collection where applicable. (Thus record boundaries are
83 not visible.)
84
85 If processing a received protocol message results in an error,
86 the callback function may not be called.  For example, the callback
87 function will never see messages that are considered too large to be
88 processed.
89
90 Due to automatic protocol version negotiation, I<version> is not
91 necessarily the protocol version used by the sender of the message: If
92 a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
93 I<version> will be B<SSL3_VERSION>.
94
95 Pseudo content type values may be sent at various points during the processing
96 of data. The following pseudo content types are currently defined:
97
98 =over 4
99
100 =item B<SSL3_RT_HEADER>
101
102 Used when a record is sent or received. The B<buf> contains the record header
103 bytes only.
104
105 =item B<SSL3_RT_INNER_CONTENT_TYPE>
106
107 Used when an encrypted TLSv1.3 record is sent or received. In encrypted TLSv1.3
108 records the content type in the record header is always
109 SSL3_RT_APPLICATION_DATA. The real content type for the record is contained in
110 an "inner" content type. B<buf> contains the encoded "inner" content type byte.
111
112 =back
113
114 =head1 SEE ALSO
115
116 L<ssl(7)>, L<SSL_new(3)>
117
118 =head1 HISTORY
119
120 The pseudo content type B<SSL3_RT_INNER_CONTENT_TYPE> was added in OpenSSL
121 1.1.1.
122
123 =head1 COPYRIGHT
124
125 Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
126
127 Licensed under the OpenSSL license (the "License").  You may not use
128 this file except in compliance with the License.  You can obtain a copy
129 in the file LICENSE in the source distribution or at
130 L<https://www.openssl.org/source/license.html>.
131
132 =cut