Import OpenSSL-0.9.8i.
[dragonfly.git] / crypto / openssl-0.9.7d / doc / ssl / SSL_CTX_set_info_callback.pod
blob63d0b8d33f87568fab08051d842476ff88389b03
1 =pod
3 =head1 NAME
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
7 =head1 SYNOPSIS
9  #include <openssl/ssl.h>
11  void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
12  void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))();
14  void SSL_set_info_callback(SSL *ssl, void (*callback)());
15  void (*SSL_get_info_callback(SSL *ssl))();
17 =head1 DESCRIPTION
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
28 B<ctx> is used.
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>.
36 =head1 NOTES
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
46 information.
48 B<where> is a bitmask made up of the following bits:
50 =over 4
52 =item SSL_CB_LOOP
54 Callback has been called to indicate state change inside a loop.
56 =item SSL_CB_EXIT
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.)
61 =item SSL_CB_READ
63 Callback has been called during read operation.
65 =item SSL_CB_WRITE
67 Callback has been called during write operation.
69 =item SSL_CB_ALERT
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.
93 =back
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.
101 =head1 RETURN VALUES
103 SSL_set_info_callback() does not provide diagnostic information.
105 SSL_get_info_callback() returns the current setting.
107 =head1 EXAMPLES
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)
113         {
114         const char *str;
115         int w;
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)
124                 {
125                 BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
126                 }
127         else if (where & SSL_CB_ALERT)
128                 {
129                 str=(where & SSL_CB_READ)?"read":"write";
130                 BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
131                         str,
132                         SSL_alert_type_string_long(ret),
133                         SSL_alert_desc_string_long(ret));
134                 }
135         else if (where & SSL_CB_EXIT)
136                 {
137                 if (ret == 0)
138                         BIO_printf(bio_err,"%s:failed in %s\n",
139                                 str,SSL_state_string_long(s));
140                 else if (ret < 0)
141                         {
142                         BIO_printf(bio_err,"%s:error in %s\n",
143                                 str,SSL_state_string_long(s));
144                         }
145                 }
146         }
148 =head1 SEE ALSO
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)>
153 =cut