5 SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback - handle information callback for SSL connections
9 #include <openssl/ssl.h>
11 void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
12 void (*SSL_CTX_get_info_callback(const SSL_CTX *ctx))();
14 void SSL_set_info_callback(SSL *ssl, void (*callback)());
15 void (*SSL_get_info_callback(const SSL *ssl))();
19 SSL_CTX_set_info_callback() sets the B<callback> function, that can be used to
20 obtain state information for SSL objects created from B<ctx> during connection
21 setup and use. The setting for B<ctx> is overridden from the setting for
22 a specific SSL object, if specified.
23 When B<callback> is NULL, not callback function is used.
25 SSL_set_info_callback() sets the B<callback> function, that can be used to
26 obtain state information for B<ssl> during connection setup and use.
27 When B<callback> is NULL, the callback setting currently valid for
30 SSL_CTX_get_info_callback() returns a pointer to the currently set information
31 callback function for B<ctx>.
33 SSL_get_info_callback() returns a pointer to the currently set information
34 callback function for B<ssl>.
38 When setting up a connection and during use, it is possible to obtain state
39 information from the SSL/TLS engine. When set, an information callback function
40 is called whenever the state changes, an alert appears, or an error occurs.
42 The callback function is called as B<callback(SSL *ssl, int where, int ret)>.
43 The B<where> argument specifies information about where (in which context)
44 the callback function was called. If B<ret> is 0, an error condition occurred.
45 If an alert is handled, SSL_CB_ALERT is set and B<ret> specifies the alert
48 B<where> is a bitmask made up of the following bits:
54 Callback has been called to indicate state change inside a loop.
58 Callback has been called to indicate error exit of a handshake function.
59 (May be soft error with retry option for non-blocking setups.)
63 Callback has been called during read operation.
67 Callback has been called during write operation.
71 Callback has been called due to an alert being sent or received.
73 =item SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
75 =item SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
77 =item SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
79 =item SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
81 =item SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
83 =item SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
85 =item SSL_CB_HANDSHAKE_START
87 Callback has been called because a new handshake is started.
89 =item SSL_CB_HANDSHAKE_DONE 0x20
91 Callback has been called because a handshake is finished.
95 The current state information can be obtained using the
96 L<SSL_state_string(3)|SSL_state_string(3)> family of functions.
98 The B<ret> information can be evaluated using the
99 L<SSL_alert_type_string(3)|SSL_alert_type_string(3)> family of functions.
103 SSL_set_info_callback() does not provide diagnostic information.
105 SSL_get_info_callback() returns the current setting.
109 The following example callback function prints state strings, information
110 about alerts being handled and error messages to the B<bio_err> BIO.
112 void apps_ssl_info_callback(SSL *s, int where, int ret)
117 w=where& ~SSL_ST_MASK;
119 if (w & SSL_ST_CONNECT) str="SSL_connect";
120 else if (w & SSL_ST_ACCEPT) str="SSL_accept";
121 else str="undefined";
123 if (where & SSL_CB_LOOP)
125 BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
127 else if (where & SSL_CB_ALERT)
129 str=(where & SSL_CB_READ)?"read":"write";
130 BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
132 SSL_alert_type_string_long(ret),
133 SSL_alert_desc_string_long(ret));
135 else if (where & SSL_CB_EXIT)
138 BIO_printf(bio_err,"%s:failed in %s\n",
139 str,SSL_state_string_long(s));
142 BIO_printf(bio_err,"%s:error in %s\n",
143 str,SSL_state_string_long(s));
150 L<ssl(3)|ssl(3)>, L<SSL_state_string(3)|SSL_state_string(3)>,
151 L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>