NAME
SSLCTXsetinfocallback, SSLCTXgetinfocallback,SSLsetinfocallback, SSLgetinfocallback - handle information
callback for SSL connectionsSYNOPSIS
#include
void SSLCTXsetinfocallback(SSLCTX *ctx, void (*callback)()); void (*SSLCTXgetinfocallback(const SSLCTX *ctx))(); void SSLsetinfocallback(SSL *ssl, void (*callback)()); void (*SSLgetinfocallback(const SSL *ssl))();DESCRIPTION
SSLCTXsetinfocallback() sets the ccaallllbbaacckk function, that can be used to obtain state information for SSL objects created from ccttxx during connection setup and use. The setting for ccttxx is overridden from the setting for a specific SSL object, if specified. When ccaallllbbaacckk is NULL, not callback function is used. SSLsetinfocallback() sets the ccaallllbbaacckk function, that can be used to obtain state information for ssssll during connection setup and use. When ccaallllbbaacckk is NULL, the callback setting currently valid for ccttxx is used. SSLCTXgetinfocallback() returns a pointer to the currently set information callback function for ccttxx. SSLgetinfocallback() returns a pointer to the currently set information callback function for ssssll. NNOOTTEESS 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 the state changes, an alert appears, or an error occurs. The callback function is called as ccaallllbbaacckk((SSSSLL **ssssll,, iinntt wwhheerree,, iinntt rreett)). The wwhheerree argument specifies information about where (in which context) the callback function was called. If rreett is 0, an error condition occurred. If an alert is handled, SSLCBALERT is set and rreett specifies the alert information. wwhheerree is a bitmask made up of the following bits: SSLCBLOOP Callback has been called to indicate state change inside a loop. SSLCBEXIT Callback has been called to indicate error exit of a handshakefunction. (May be soft error with retry option for non-blocking
setups.) SSLCBREAD Callback has been called during read operation. SSLCBWRITE Callback has been called during write operation. SSLCBALERT Callback has been called due to an alert being sent or received. SSLCBREADALERT (SSLCBALERT|SSLCBREAD) SSLCBWRITEALERT (SSLCBALERT|SSLCBWRITE) SSLCBACCEPTLOOP (SSLSTACCEPT|SSLCBLOOP) SSLCBACCEPTEXIT (SSLSTACCEPT|SSLCBEXIT) SSLCBCONNECTLOOP (SSLSTCONNECT|SSLCBLOOP) SSLCBCONNECTEXIT (SSLSTCONNECT|SSLCBEXIT) SSLCBHANDSHAKESTART Callback has been called because a new handshake is started. SSLCBHANDSHAKEDONE 0x20 Callback has been called because a handshake is finished. The current state information can be obtained using the SSLstatestring(3) family of functions. The rreett information can be evaluated using the SSLalerttypestring(3) family of functions.RETURN VALUES
SSLsetinfocallback() does not provide diagnostic information. SSLgetinfocallback() returns the current setting. EEXXAAMMPPLLEESS The following example callback function prints state strings, information about alerts being handled and error messages to the bbiiooeerrrr BIO. void appssslinfocallback(SSL *s, int where, int ret) { const char *str; int w; w=where& ~SSLSTMASK; if (w & SSLSTCONNECT) str="SSLconnect"; else if (w & SSLSTACCEPT) str="SSLaccept"; else str="undefined"; if (where & SSLCBLOOP) {BIOprintf(bioerr,"%s:%s\n",str,SSLstatestringlong(s));
} else if (where & SSLCBALERT) { str=(where & SSLCBREAD)?"read":"write";BIOprintf(bioerr,"SSL3 alert %s:%s:%s\n",
str, SSLalerttypestringlong(ret), SSLalertdescstringlong(ret)); } else if (where & SSLCBEXIT) { if (ret == 0)BIOprintf(bioerr,"%s:failed in %s\n",
str,SSLstatestringlong(s)); else if (ret < 0) {BIOprintf(bioerr,"%s:error in %s\n",
str,SSLstatestringlong(s)); } } }SEE ALSO
ssl(3), SSLstatestring(3), SSLalerttypestring(3)0.9.7l 2005-03-30 SSLCTXsetinfocallback(3)