gnutls_alert_send_appropriate - Linux
Overview
gnutls_alert_send_appropriate generates an alert, which is added to the session queue to be sent to the peer. The alert is determined based on the specified error code, if specified, or the error provided by the session.
Syntax
gnutls_alert_send_appropriate(gnutls_session_t session, int error);
Options/Flags
| Option | Description | Default |
|—|—|—|
| error | The error code (see gnutls_error.h) | The error provided by the session |
Examples
Sending a warning alert:
int ret = gnutls_alert_send_appropriate(session, GNUTLS_E_WARNING_ALERT_RECEIVED);
Sending a fatal alert due to a handshake error:
int err = gnutls_alert_send_appropriate(session, GNUTLS_E_HANDSHAKE_FAILURE);
Common Issues
If the error code is not specified, the session’s error will be used. However, if the session does not contain an error, no alert will be sent. To send an alert even when there is no session error, specify an error code.
Integration
gnutls_alert_send_appropriate can be used with other GnuTLS functions, such as gnutls_session_get_error() to retrieve the session’s error code, or gnutls_alert_send() to send a custom alert.