import libssl (LibreSSL 2.5.4)
[unleashed.git] / lib / libssl / man / SSL_CTX_set_msg_callback.3
blob33d62a683778beef11a0526b00a1e8cfffadfa6a
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
3 .\"
4 .\" This file was written by Bodo Moeller <bodo@openssl.org>.
5 .\" Copyright (c) 2001, 2014, 2016 The OpenSSL Project.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\"
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
17 .\"    distribution.
18 .\"
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/)"
23 .\"
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.
28 .\"
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.
32 .\"
33 .\" 6. Redistributions of any form whatsoever must retain the following
34 .\"    acknowledgment:
35 .\"    "This product includes software developed by the OpenSSL Project
36 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 .\"
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.
50 .\"
51 .Dd $Mdocdate: December 1 2016 $
52 .Dt SSL_CTX_SET_MSG_CALLBACK 3
53 .Os
54 .Sh NAME
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
60 .Sh SYNOPSIS
61 .In openssl/ssl.h
62 .Ft void
63 .Fo SSL_CTX_set_msg_callback
64 .Fa "SSL_CTX *ctx"
65 .Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
66 .Fc
67 .Ft void
68 .Fn SSL_CTX_set_msg_callback_arg "SSL_CTX *ctx" "void *arg"
69 .Ft void
70 .Fo SSL_set_msg_callback
71 .Fa "SSL *ssl"
72 .Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
73 .Fc
74 .Ft void
75 .Fn SSL_set_msg_callback_arg "SSL *ssl" "void *arg"
76 .Sh DESCRIPTION
77 .Fn SSL_CTX_set_msg_callback
79 .Fn SSL_set_msg_callback
80 can be used to define a message callback function
81 .Fa cb
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
85 and
86 .Fn SSL_set_msg_callback_arg
87 can be used to set argument
88 .Fa arg
89 to the callback function, which is available for arbitrary application use.
90 .Pp
91 .Fn SSL_CTX_set_msg_callback
92 and
93 .Fn SSL_CTX_set_msg_callback_arg
94 specify default settings that will be copied to new
95 .Vt SSL
96 objects by
97 .Xr SSL_new 3 .
98 .Fn SSL_set_msg_callback
99 and
100 .Fn SSL_set_msg_callback_arg
101 modify the actual settings of an
102 .Vt SSL
103 object.
104 Using a
105 .Dv NULL
106 pointer for
107 .Fa cb
108 disables the message callback.
110 When
111 .Fa cb
112 is called by the SSL/TLS library for a protocol message,
113 the function arguments have the following meaning:
114 .Bl -tag -width Ds
115 .It Fa write_p
116 This flag is 0 when a protocol message has been received and 1 when a protocol
117 message has been sent.
118 .It Fa version
119 The protocol version according to which the protocol message is
120 interpreted by the library.
121 Currently, this is one of
122 .Dv SSL2_VERSION ,
123 .Dv SSL3_VERSION
125 .Dv TLS1_VERSION
126 (for SSL 2.0, SSL 3.0 and TLS 1.0, respectively).
127 .It Fa content_type
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
130 .Em ContentType
131 values defined in the protocol specification
133 .Dq change_cipher_spec(20) ,
134 .Dq alert(21) ,
135 .Dq handshake(22) ;
136 but never
137 .Dq application_data(23)
138 because the callback will only be called for protocol messages.
140 .It Fa buf , Fa len
141 .Fa buf
142 points to a buffer containing the protocol message, which consists of
143 .Fa len
144 bytes.
145 The buffer is no longer valid after the callback function has returned.
146 .It Fa ssl
148 .Vt SSL
149 object that received or sent the message.
150 .It Fa arg
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,
167 .Fa version
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,
170 .Fa version
171 will be
172 .Dv SSL3_VERSION .
173 .Sh SEE ALSO
174 .Xr ssl 3 ,
175 .Xr SSL_new 3
176 .Sh HISTORY
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.