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
8       callback 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
22       during 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
34       information 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
45       condition occurred.  If an alert is handled, SSL_CB_ALERT is set and
46       ret 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,
92       information about alerts being handled and error messages to the
93       bio_err BIO.
94
95        void apps_ssl_info_callback(SSL *s, int where, int ret)
96               {
97               const char *str;
98               int w;
99
100               w=where& ~SSL_ST_MASK;
101
102               if (w & SSL_ST_CONNECT) str="SSL_connect";
103               else if (w & SSL_ST_ACCEPT) str="SSL_accept";
104               else str="undefined";
105
106               if (where & SSL_CB_LOOP)
107                       {
108                       BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
109                       }
110               else if (where & SSL_CB_ALERT)
111                       {
112                       str=(where & SSL_CB_READ)?"read":"write";
113                       BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
114                               str,
115                               SSL_alert_type_string_long(ret),
116                               SSL_alert_desc_string_long(ret));
117                       }
118               else if (where & SSL_CB_EXIT)
119                       {
120                       if (ret == 0)
121                               BIO_printf(bio_err,"%s:failed in %s\n",
122                                       str,SSL_state_string_long(s));
123                       else if (ret < 0)
124                               {
125                               BIO_printf(bio_err,"%s:error in %s\n",
126                                       str,SSL_state_string_long(s));
127                               }
128                       }
129               }
130

SEE ALSO

132       ssl(3), SSL_state_string(3), SSL_alert_type_string(3)
133
134
135
1361.0.2o                            2019-09-10      SSL_CTX_set_info_callback(3)
Impressum