xref: /netbsd-src/crypto/external/bsd/openssl/lib/libcrypto/man/SSL_CTX_set_info_callback.3 (revision 7d9ffdb3e9da593a05c5e2169f72fc7bada08bc9)
$NetBSD: SSL_CTX_set_info_callback.3,v 1.25 2024/09/08 13:08:32 christos Exp $

-*- mode: troff; coding: utf-8 -*-
Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)

Standard preamble:
========================================================================
..
..
.. \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
. ds C` "" . ds C' "" 'br\} . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF ========================================================================

Title "SSL_CTX_set_info_callback 3"
SSL_CTX_set_info_callback 3 2024-09-03 3.0.15 OpenSSL
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
NAME
SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback \- handle information callback for SSL connections
SYNOPSIS
Header "SYNOPSIS" .Vb 1 #include <openssl/ssl.h> \& void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback) (const SSL *ssl, int type, int val)); \& void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type, int val); \& void SSL_set_info_callback(SSL *ssl, void (*callback) (const SSL *ssl, int type, int val)); \& void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, int val); .Ve
DESCRIPTION
Header "DESCRIPTION" \fBSSL_CTX_set_info_callback() sets the callback function, that can be used to obtain state information for SSL objects created from ctx during connection setup and use. The setting for ctx is overridden from the setting for a specific SSL object, if specified. When callback is NULL, no callback function is used.

\fBSSL_set_info_callback() sets the callback function, that can be used to obtain state information for ssl during connection setup and use. When callback is NULL, the callback setting currently valid for \fBctx is used.

\fBSSL_CTX_get_info_callback() returns a pointer to the currently set information callback function for ctx.

\fBSSL_get_info_callback() returns a pointer to the currently set information callback function for ssl.

NOTES
Header "NOTES" When setting up a connection and during use, it is possible to obtain state information from the SSL/TLS engine. When set, an information callback function is called whenever a significant event occurs such as: the state changes, an alert appears, or an error occurs.

The callback function is called as callback(SSL *ssl, int where, int ret). The where argument specifies information about where (in which context) the callback function was called. If ret is 0, an error condition occurred. If an alert is handled, SSL_CB_ALERT is set and ret specifies the alert information.

\fBwhere is a bit-mask made up of the following bits:

SSL_CB_LOOP 4
Item "SSL_CB_LOOP" Callback has been called to indicate state change or some other significant state machine event. This may mean that the callback gets invoked more than once per state in some situations.
SSL_CB_EXIT 4
Item "SSL_CB_EXIT" Callback has been called to indicate exit of a handshake function. This will happen after the end of a handshake, but may happen at other times too such as on error or when IO might otherwise block and nonblocking is being used.
SSL_CB_READ 4
Item "SSL_CB_READ" Callback has been called during read operation.
SSL_CB_WRITE 4
Item "SSL_CB_WRITE" Callback has been called during write operation.
SSL_CB_ALERT 4
Item "SSL_CB_ALERT" Callback has been called due to an alert being sent or received.
"SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)" 4
Item "SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)"

0

"SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)" 4
Item "SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)"
"SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)" 4
Item "SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)"
"SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)" 4
Item "SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)"
"SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)" 4
Item "SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)"
"SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)" 4
Item "SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)"
SSL_CB_HANDSHAKE_START 4
Item "SSL_CB_HANDSHAKE_START"

Callback has been called because a new handshake is started. It also occurs when resuming a handshake following a pause to handle early data.

SSL_CB_HANDSHAKE_DONE 4
Item "SSL_CB_HANDSHAKE_DONE" Callback has been called because a handshake is finished. It also occurs if the handshake is paused to allow the exchange of early data.

The current state information can be obtained using the \fBSSL_state_string\|(3) family of functions.

The ret information can be evaluated using the \fBSSL_alert_type_string\|(3) family of functions.

"RETURN VALUES"
Header "RETURN VALUES" \fBSSL_set_info_callback() does not provide diagnostic information.

\fBSSL_get_info_callback() returns the current setting.

EXAMPLES
Header "EXAMPLES" The following example callback function prints state strings, information about alerts being handled and error messages to the bio_err BIO.

.Vb 4 void apps_ssl_info_callback(const SSL *s, int where, int ret) { const char *str; int w = where & ~SSL_ST_MASK; \& if (w & SSL_ST_CONNECT) str = "SSL_connect"; else if (w & SSL_ST_ACCEPT) str = "SSL_accept"; else str = "undefined"; \& if (where & SSL_CB_LOOP) { BIO_printf(bio_err, "%s:%s\en", str, SSL_state_string_long(s)); } else if (where & SSL_CB_ALERT) { str = (where & SSL_CB_READ) ? "read" : "write"; BIO_printf(bio_err, "SSL3 alert %s:%s:%s\en", str, SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret)); } else if (where & SSL_CB_EXIT) { if (ret == 0) { BIO_printf(bio_err, "%s:failed in %s\en", str, SSL_state_string_long(s)); } else if (ret < 0) { BIO_printf(bio_err, "%s:error in %s\en", str, SSL_state_string_long(s)); } } } .Ve

"SEE ALSO"
Header "SEE ALSO" \fBssl\|(7), SSL_state_string\|(3), \fBSSL_alert_type_string\|(3)
COPYRIGHT
Header "COPYRIGHT" Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.