Debian Codegraph @

upstream/debian-unstable/man3/SSL_CTX_set_info_callback.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "SSL_CTX_SET_INFO_CALLBACK 3SSL"
58 .TH SSL_CTX_SET_INFO_CALLBACK 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 SSL_CTX_set_info_callback,
65 SSL_CTX_get_info_callback,
66 SSL_set_info_callback,
67 SSL_get_info_callback
68 \&\- handle information callback for SSL connections
69 .SH SYNOPSIS
70 .IX Header "SYNOPSIS"
71 .Vb 1
72 \& #include <openssl/ssl.h>
73 \&
74 \& void SSL_CTX_set_info_callback(SSL_CTX *ctx,
75 \& void (*callback) (const SSL *ssl, int type, int val));
76 \&
77 \& void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type, int val);
78 \&
79 \& void SSL_set_info_callback(SSL *ssl,
80 \& void (*callback) (const SSL *ssl, int type, int val));
81 \&
82 \& void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, int val);
83 .Ve
84 .SH DESCRIPTION
85 .IX Header "DESCRIPTION"
86 \&\fBSSL_CTX_set_info_callback()\fR sets the \fBcallback\fR function, that can be used to
87 obtain state information for SSL objects created from \fBctx\fR during connection
88 setup and use. The setting for \fBctx\fR is overridden from the setting for
89 a specific SSL object, if specified.
90 When \fBcallback\fR is NULL, no callback function is used.
91 .PP
92 \&\fBSSL_set_info_callback()\fR sets the \fBcallback\fR function, that can be used to
93 obtain state information for \fBssl\fR during connection setup and use.
94 When \fBcallback\fR is NULL, the callback setting currently valid for
95 \&\fBctx\fR is used. \fBssl\fR \fBMUST NOT\fR be NULL.
96 .PP
97 \&\fBSSL_CTX_get_info_callback()\fR returns a pointer to the currently set information
98 callback function for \fBctx\fR.
99 .PP
100 \&\fBSSL_get_info_callback()\fR returns a pointer to the currently set information
101 callback function for \fBssl\fR.
102 .SH NOTES
103 .IX Header "NOTES"
104 When setting up a connection and during use, it is possible to obtain state
105 information from the SSL/TLS engine. When set, an information callback function
106 is called whenever a significant event occurs such as: the state changes,
107 an alert appears, or an error occurs.
108 .PP
109 The callback function is called as \fBcallback(SSL *ssl, int where, int ret)\fR.
110 The \fBwhere\fR argument specifies information about where (in which context)
111 the callback function was called. If \fBret\fR is 0, an error condition occurred.
112 If an alert is handled, SSL_CB_ALERT is set and \fBret\fR specifies the alert
113 information.
114 .PP
115 \&\fBwhere\fR is a bit-mask made up of the following bits:
116 .IP SSL_CB_LOOP 4
117 .IX Item "SSL_CB_LOOP"
118 Callback has been called to indicate state change or some other significant
119 state machine event. This may mean that the callback gets invoked more than once
120 per state in some situations.
121 .IP SSL_CB_EXIT 4
122 .IX Item "SSL_CB_EXIT"
123 Callback has been called to indicate exit of a handshake function. This will
124 happen after the end of a handshake, but may happen at other times too such as
125 on error or when IO might otherwise block and nonblocking is being used.
126 .IP SSL_CB_READ 4
127 .IX Item "SSL_CB_READ"
128 Callback has been called during read operation.
129 .IP SSL_CB_WRITE 4
130 .IX Item "SSL_CB_WRITE"
131 Callback has been called during write operation.
132 .IP SSL_CB_ALERT 4
133 .IX Item "SSL_CB_ALERT"
134 Callback has been called due to an alert being sent or received.
135 .IP "SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)" 4
136 .IX Item "SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)"
137 .PD 0
138 .IP "SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)" 4
139 .IX Item "SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)"
140 .IP "SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)" 4
141 .IX Item "SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)"
142 .IP "SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)" 4
143 .IX Item "SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)"
144 .IP "SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)" 4
145 .IX Item "SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)"
146 .IP "SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)" 4
147 .IX Item "SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)"
148 .IP SSL_CB_HANDSHAKE_START 4
149 .IX Item "SSL_CB_HANDSHAKE_START"
150 .PD
151 Callback has been called because a new handshake is started. It also occurs when
152 resuming a handshake following a pause to handle early data.
153 .IP SSL_CB_HANDSHAKE_DONE 4
154 .IX Item "SSL_CB_HANDSHAKE_DONE"
155 Callback has been called because a handshake is finished. It also occurs if the
156 handshake is paused to allow the exchange of early data.
157 .PP
158 The current state information can be obtained using the
159 \&\fBSSL_state_string\fR\|(3) family of functions.
160 .PP
161 The \fBret\fR information can be evaluated using the
162 \&\fBSSL_alert_type_string\fR\|(3) family of functions.
163 .SH "RETURN VALUES"
164 .IX Header "RETURN VALUES"
165 \&\fBSSL_set_info_callback()\fR does not provide diagnostic information.
166 .PP
167 \&\fBSSL_get_info_callback()\fR returns the current setting.
168 .SH EXAMPLES
169 .IX Header "EXAMPLES"
170 The following example callback function prints state strings, information
171 about alerts being handled and error messages to the \fBbio_err\fR BIO.
172 .PP
173 .Vb 4
174 \& void apps_ssl_info_callback(const SSL *s, int where, int ret)
175 \& {
176 \& const char *str;
177 \& int w = where & ~SSL_ST_MASK;
178 \&
179 \& if (w & SSL_ST_CONNECT)
180 \& str = "SSL_connect";
181 \& else if (w & SSL_ST_ACCEPT)
182 \& str = "SSL_accept";
183 \& else
184 \& str = "undefined";
185 \&
186 \& if (where & SSL_CB_LOOP) {
187 \& BIO_printf(bio_err, "%s:%s\en", str, SSL_state_string_long(s));
188 \& } else if (where & SSL_CB_ALERT) {
189 \& str = (where & SSL_CB_READ) ? "read" : "write";
190 \& BIO_printf(bio_err, "SSL3 alert %s:%s:%s\en", str,
191 \& SSL_alert_type_string_long(ret),
192 \& SSL_alert_desc_string_long(ret));
193 \& } else if (where & SSL_CB_EXIT) {
194 \& if (ret == 0) {
195 \& BIO_printf(bio_err, "%s:failed in %s\en",
196 \& str, SSL_state_string_long(s));
197 \& } else if (ret < 0) {
198 \& BIO_printf(bio_err, "%s:error in %s\en",
199 \& str, SSL_state_string_long(s));
200 \& }
201 \& }
202 \& }
203 .Ve
204 .SH "SEE ALSO"
205 .IX Header "SEE ALSO"
206 \&\fBssl\fR\|(7), \fBSSL_state_string\fR\|(3),
207 \&\fBSSL_alert_type_string\fR\|(3)
208 .SH COPYRIGHT
209 .IX Header "COPYRIGHT"
210 Copyright 2001\-2020 The OpenSSL Project Authors. All Rights Reserved.
211 .PP
212 Licensed under the Apache License 2.0 (the "License"). You may not use
213 this file except in compliance with the License. You can obtain a copy
214 in the file LICENSE in the source distribution or at
215 <https://www.openssl.org/source/license.html>.