1SSL_CTX_set_info_callback(3)        OpenSSL       SSL_CTX_set_info_callback(3)
2
3
4

NAME

6       SSL_CTX_set_info_callback, SSL_CTX_get_info_callback,
7       SSL_set_info_callback, SSL_get_info_callback - handle information call‐
8       back for SSL connections
9

SYNOPSIS

11        #include <openssl/ssl.h>
12
13        void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
14        void (*SSL_CTX_get_info_callback(const SSL_CTX *ctx))();
15
16        void SSL_set_info_callback(SSL *ssl, void (*callback)());
17        void (*SSL_get_info_callback(const SSL *ssl))();
18

DESCRIPTION

20       SSL_CTX_set_info_callback() sets the callback function, that can be
21       used to obtain state information for SSL objects created from ctx dur‐
22       ing connection setup and use. The setting for ctx is overridden from
23       the setting for a specific SSL object, if specified.  When callback is
24       NULL, not callback function is used.
25
26       SSL_set_info_callback() sets the callback function, that can be used to
27       obtain state information for ssl during connection setup and use.  When
28       callback is NULL, the callback setting currently valid for ctx is used.
29
30       SSL_CTX_get_info_callback() returns a pointer to the currently set
31       information callback function for ctx.
32
33       SSL_get_info_callback() returns a pointer to the currently set informa‐
34       tion callback function for ssl.
35

NOTES

37       When setting up a connection and during use, it is possible to obtain
38       state information from the SSL/TLS engine. When set, an information
39       callback function is called whenever the state changes, an alert
40       appears, or an error occurs.
41
42       The callback function is called as callback(SSL *ssl, int where, int
43       ret).  The where argument specifies information about where (in which
44       context) the callback function was called. If ret is 0, an error condi‐
45       tion occurred.  If an alert is handled, SSL_CB_ALERT is set and ret
46       specifies the alert information.
47
48       where is a bitmask made up of the following bits:
49
50       SSL_CB_LOOP
51           Callback has been called to indicate state change inside a loop.
52
53       SSL_CB_EXIT
54           Callback has been called to indicate error exit of a handshake
55           function.  (May be soft error with retry option for non-blocking
56           setups.)
57
58       SSL_CB_READ
59           Callback has been called during read operation.
60
61       SSL_CB_WRITE
62           Callback has been called during write operation.
63
64       SSL_CB_ALERT
65           Callback has been called due to an alert being sent or received.
66
67       SSL_CB_READ_ALERT               (SSL_CB_ALERT⎪SSL_CB_READ)
68       SSL_CB_WRITE_ALERT              (SSL_CB_ALERT⎪SSL_CB_WRITE)
69       SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT⎪SSL_CB_LOOP)
70       SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT⎪SSL_CB_EXIT)
71       SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT⎪SSL_CB_LOOP)
72       SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT⎪SSL_CB_EXIT)
73       SSL_CB_HANDSHAKE_START
74           Callback has been called because a new handshake is started.
75
76       SSL_CB_HANDSHAKE_DONE           0x20
77           Callback has been called because a handshake is finished.
78
79       The current state information can be obtained using the
80       SSL_state_string(3) family of functions.
81
82       The ret information can be evaluated using the SSL_alert_type_string(3)
83       family of functions.
84

RETURN VALUES

86       SSL_set_info_callback() does not provide diagnostic information.
87
88       SSL_get_info_callback() returns the current setting.
89

EXAMPLES

91       The following example callback function prints state strings, informa‐
92       tion about alerts being handled and error messages to the bio_err BIO.
93
94        void apps_ssl_info_callback(SSL *s, int where, int ret)
95               {
96               const char *str;
97               int w;
98
99               w=where& ~SSL_ST_MASK;
100
101               if (w & SSL_ST_CONNECT) str="SSL_connect";
102               else if (w & SSL_ST_ACCEPT) str="SSL_accept";
103               else str="undefined";
104
105               if (where & SSL_CB_LOOP)
106                       {
107                       BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
108                       }
109               else if (where & SSL_CB_ALERT)
110                       {
111                       str=(where & SSL_CB_READ)?"read":"write";
112                       BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
113                               str,
114                               SSL_alert_type_string_long(ret),
115                               SSL_alert_desc_string_long(ret));
116                       }
117               else if (where & SSL_CB_EXIT)
118                       {
119                       if (ret == 0)
120                               BIO_printf(bio_err,"%s:failed in %s\n",
121                                       str,SSL_state_string_long(s));
122                       else if (ret < 0)
123                               {
124                               BIO_printf(bio_err,"%s:error in %s\n",
125                                       str,SSL_state_string_long(s));
126                               }
127                       }
128               }
129

SEE ALSO

131       ssl(3), SSL_state_string(3), SSL_alert_type_string(3)
132
133
134
1350.9.8b                            2005-03-30      SSL_CTX_set_info_callback(3)
Impressum