1 .\" $OpenBSD: SSL_CTX_set_msg_callback.3,v 1.2 2016/12/01 15:26:11 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Bodo Moeller <bodo@openssl.org>.
5 .\" Copyright (c) 2001, 2014, 2016 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in
16 .\" the documentation and/or other materials provided with the
19 .\" 3. All advertising materials mentioning features or use of this
20 .\" software must display the following acknowledgment:
21 .\" "This product includes software developed by the OpenSSL Project
22 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\" endorse or promote products derived from this software without
26 .\" prior written permission. For written permission, please contact
27 .\" openssl-core@openssl.org.
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\" nor may "OpenSSL" appear in their names without prior written
31 .\" permission of the OpenSSL Project.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .Dd $Mdocdate: December 1 2016 $
52 .Dt SSL_CTX_SET_MSG_CALLBACK 3
55 .Nm SSL_CTX_set_msg_callback ,
56 .Nm SSL_CTX_set_msg_callback_arg ,
57 .Nm SSL_set_msg_callback ,
58 .Nm SSL_set_msg_callback_arg
59 .Nd install callback for observing protocol messages
63 .Fo SSL_CTX_set_msg_callback
65 .Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
68 .Fn SSL_CTX_set_msg_callback_arg "SSL_CTX *ctx" "void *arg"
70 .Fo SSL_set_msg_callback
72 .Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
75 .Fn SSL_set_msg_callback_arg "SSL *ssl" "void *arg"
77 .Fn SSL_CTX_set_msg_callback
79 .Fn SSL_set_msg_callback
80 can be used to define a message callback function
82 for observing all SSL/TLS protocol messages (such as handshake messages)
83 that are received or sent.
84 .Fn SSL_CTX_set_msg_callback_arg
86 .Fn SSL_set_msg_callback_arg
87 can be used to set argument
89 to the callback function, which is available for arbitrary application use.
91 .Fn SSL_CTX_set_msg_callback
93 .Fn SSL_CTX_set_msg_callback_arg
94 specify default settings that will be copied to new
98 .Fn SSL_set_msg_callback
100 .Fn SSL_set_msg_callback_arg
101 modify the actual settings of an
108 disables the message callback.
112 is called by the SSL/TLS library for a protocol message,
113 the function arguments have the following meaning:
116 This flag is 0 when a protocol message has been received and 1 when a protocol
117 message has been sent.
119 The protocol version according to which the protocol message is
120 interpreted by the library.
121 Currently, this is one of
126 (for SSL 2.0, SSL 3.0 and TLS 1.0, respectively).
128 In the case of SSL 2.0, this is always 0.
129 In the case of SSL 3.0 or TLS 1.0, this is one of the
131 values defined in the protocol specification
133 .Dq change_cipher_spec(20) ,
137 .Dq application_data(23)
138 because the callback will only be called for protocol messages.
142 points to a buffer containing the protocol message, which consists of
145 The buffer is no longer valid after the callback function has returned.
149 object that received or sent the message.
151 The user-defined argument optionally defined by
152 .Fn SSL_CTX_set_msg_callback_arg
154 .Fn SSL_set_msg_callback_arg .
157 Protocol messages are passed to the callback function after decryption
158 and fragment collection where applicable.
159 (Thus record boundaries are not visible.)
161 If processing a received protocol message results in an error,
162 the callback function may not be called.
163 For example, the callback function will never see messages that are considered
164 too large to be processed.
166 Due to automatic protocol version negotiation,
168 is not necessarily the protocol version used by the sender of the message:
169 If a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
177 .Fn SSL_CTX_set_msg_callback ,
178 .Fn SSL_CTX_set_msg_callback_arg ,
179 .Fn SSL_set_msg_callback
181 .Fn SSL_set_msg_callback_arg
182 were added in OpenSSL 0.9.7.