TLS Events
TLS Event Callback¶
TLS event callbacks are called by libESMTP when initialising or negotiating a TLS secure connection.
The callback function signature varies depending on the event type described below.
-
void weak_cipher(smtp_session_t session, int event_no, void *arg, int bits, int *ok)¶
SMTP_EV_WEAK_CIPHER event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_WEAK_CIPHERvoid *argapplication data (closure) specified to smtp_set_eventcb().
int bitsBits in cipher key
int *okSet zero to quit SMTP session, non-zero to continue.
Description
Report that a weak cipher was negotiated. By default a key of 40 bits or less is considered weak and libESMTP will reject the connection. This cannot be the case when TLS is used, however an application may supply an SSL_CTX supporting legacy SSL versions.
-
void starttls_ok(smtp_session_t session, int event_no, void *arg, SSL *ssl, const char *cipher, int bits)¶
SMTP_EV_STARTTLS_OK event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_STARTTLS_OKvoid *argapplication data (closure) specified to smtp_set_eventcb().
SSL *sslThe OpenSSL TLS context.
const char *cipherName of negotiated cipher.
int bitscipher key size in bits.
Description
Report a successful TLS connection and the cipher details. The OpenSSL context is passed so that the application may query further information.
-
void invalid_peer_certificate(smtp_session_t session, int event_no, void *arg, long verify, int *ok, SSL *ssl)¶
SMTP_EV_INVALID_PEER_CERTIFICATE event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_INVALID_PEER_CERTIFICATEvoid *argapplication data (closure) specified to smtp_set_eventcb().
long verifyReturn value from SSL_get_verify_result().
int *okSet zero to quit SMTP session, non-zero to continue.
SSL *sslThe OpenSSL TLS context.
Description
Report an invalid peer certificate. The TLS context, ssl, and verify provide information on the reason for the invalid certificate. By default libESMTP will reject the connection.
-
void no_peer_certificate(smtp_session_t session, int event_no, void *arg, int *ok)¶
SMTP_EV_NO_PEER_CERTIFICATE event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_NO_PEER_CERTIFICATEvoid *argapplication data (closure) specified to smtp_set_eventcb().
int *okSet zero to quit SMTP session, non-zero to continue.
Description
Report that peer did not present a certficate. By default libESMTP will reject the connection.
-
void wrong_peer_certificate(smtp_session_t session, int event_no, void *arg, int *ok, const char *domain, SSL *ssl)¶
SMTP_EV_WRONG_PEER_CERTIFICATE event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_WRONG_PEER_CERTIFICATEvoid *argapplication data (closure) specified to smtp_set_eventcb().
int *okSet zero to quit SMTP session, non-zero to continue.
const char *domainCertificate domain.
SSL *sslThe OpenSSL TLS context.
Description
Report that the server certificate is not valid for the domain name used to connect to the peer. The actual domain is provided in domain which may contain wildcards. By default libESMTP will reject the connection.
-
void no_client_certificate(smtp_session_t session, int event_no, void *arg, int *ok)¶
SMTP_EV_NO_CLIENT_CERTIFICATE event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_NO_CLIENT_CERTIFICATEvoid *argapplication data (closure) specified to smtp_set_eventcb().
int *okSet zero to quit SMTP session, non-zero to continue.
Description
Report that a private key could not be found for a certificate libESMTP has attempted to load when initialising an OpenSSL TLS context. By default libESMTP will not continue to set up the TLS connection. Note that this is different to not providing a client certificate at all.
-
void unusable_client_certificate(smtp_session_t session, int event_no, void *arg, void *null)¶
SMTP_EV_UNUSABLE_CLIENT_CERTIFICATE event
Parameters
smtp_session_t sessionThe session.
int event_noEqual to
SMTP_EV_UNUSABLE_CLIENT_CERTIFICATEvoid *argapplication data (closure) specified to smtp_set_eventcb().
void *nullalways
NULL
Description
Report a file error when attempting to load a client certificate. libESMTP will not make TLS connections until the error is corrected.