gnutls_alert_set_read_function - Linux


Overview

The gnutls_alert_set_read_function function sets the alert message callback function for the given tls_session. This function will be called upon receipt of an alert message from the TLS connection.

Syntax

bool gnutls_alert_set_read_function(gnutls_session_t session, gnutls_alert_read_func read_func)

Options/Flags

  • read_func: The callback function to set for TLS alert messages. Two arguments are passed to the callback function: a pointer to the gnutls_session_t and a pointer to the alert message.

Examples

// Set the alert read function
gnutls_alert_read_func read_func = [](gnutls_session_t session, const gnutls_alert_message* alert) {
  printf("Received alert: %d, %d\n", alert->level, alert->description);
  return 0;
};

gnutls_alert_set_read_function(session, read_func);

Common Issues

  • Ensure that the callback function is set before the connection is established.
  • The callback function should handle the alert message in a timely manner to avoid blocking the TLS connection.

Integration

This function can be used with other GNU TLS functions to handle TLS alerts and messages.

Related Commands