1 .\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.2 2016/11/30 18:29:14 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
5 .\" Copyright (c) 2001, 2005, 2014 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: November 30 2016 $
52 .Dt SSL_CTX_SET_INFO_CALLBACK 3
55 .Nm SSL_CTX_set_info_callback ,
56 .Nm SSL_CTX_get_info_callback ,
57 .Nm SSL_set_info_callback ,
58 .Nm SSL_get_info_callback
59 .Nd handle information callback for SSL connections
63 .Fo SSL_CTX_set_info_callback
65 .Fa "void (*callback)(const SSL *ssl, int where, int ret)"
68 .Fo "(*SSL_CTX_get_info_callback(const SSL_CTX *ctx))"
74 .Fo SSL_set_info_callback
76 .Fa "void (*callback)(const SSL *ssl, int where, int ret)"
79 .Fo "(*SSL_get_info_callback(const SSL *ssl))"
85 .Fn SSL_CTX_set_info_callback
88 function that can be used to obtain state information for SSL objects created
91 during connection setup and use.
94 is overridden from the setting for a specific SSL object, if specified.
99 no callback function is used.
101 .Fn SSL_set_info_callback
104 function that can be used to
105 obtain state information for
107 during connection setup and use.
112 the callback setting currently valid for
116 .Fn SSL_CTX_get_info_callback
117 returns a pointer to the currently set information callback function for
120 .Fn SSL_get_info_callback
121 returns a pointer to the currently set information callback function for
124 When setting up a connection and during use,
125 it is possible to obtain state information from the SSL/TLS engine.
126 When set, an information callback function is called whenever the state changes,
127 an alert appears, or an error occurs.
129 The callback function is called as
130 .Fn callback "SSL *ssl" "int where" "int ret" .
133 argument specifies information about where (in which context)
134 the callback function was called.
137 is 0, an error condition occurred.
138 If an alert is handled,
142 specifies the alert information.
145 is a bitmask made up of the following bits:
148 Callback has been called to indicate state change inside a loop.
150 Callback has been called to indicate error exit of a handshake function.
151 (May be soft error with retry option for non-blocking setups.)
153 Callback has been called during read operation.
155 Callback has been called during write operation.
157 Callback has been called due to an alert being sent or received.
158 .It Dv SSL_CB_READ_ALERT
159 .It Dv SSL_CB_WRITE_ALERT
160 .It Dv SSL_CB_ACCEPT_LOOP
161 .It Dv SSL_CB_ACCEPT_EXIT
162 .It Dv SSL_CB_CONNECT_LOOP
163 .It Dv SSL_CB_CONNECT_EXIT
164 .It Dv SSL_CB_HANDSHAKE_START
165 Callback has been called because a new handshake is started.
166 .It Dv SSL_CB_HANDSHAKE_DONE
167 Callback has been called because a handshake is finished.
170 The current state information can be obtained using the
171 .Xr SSL_state_string 3
176 information can be evaluated using the
177 .Xr SSL_alert_type_string 3
180 .Fn SSL_CTX_get_info_callback
182 .Fn SSL_get_info_callback
183 return a pointer to the current callback or
187 The following example callback function prints state strings,
188 information about alerts being handled and error messages to the
193 apps_ssl_info_callback(SSL *s, int where, int ret)
198 w = where & ~SSL_ST_MASK;
200 if (w & SSL_ST_CONNECT)
202 else if (w & SSL_ST_ACCEPT)
207 if (where & SSL_CB_LOOP) {
208 BIO_printf(bio_err, "%s:%s\en", str,
209 SSL_state_string_long(s));
210 } else if (where & SSL_CB_ALERT) {
211 str = (where & SSL_CB_READ) ? "read" : "write";
212 BIO_printf(bio_err, "SSL3 alert %s:%s:%s\en", str,
213 SSL_alert_type_string_long(ret),
214 SSL_alert_desc_string_long(ret));
215 } else if (where & SSL_CB_EXIT) {
217 BIO_printf(bio_err, "%s:failed in %s\en",
218 str, SSL_state_string_long(s));
220 BIO_printf(bio_err, "%s:error in %s\en",
221 str, SSL_state_string_long(s));
228 .Xr SSL_alert_type_string 3 ,
229 .Xr SSL_state_string 3