1 /* This example code is placed in the public domain. */
9 #include <gnutls/gnutls.h>
13 /* This function will check whether the given return code from
14 * a gnutls function (recv/send), is an alert, and will print
18 check_alert (gnutls_session_t session
, int ret
)
22 if (ret
== GNUTLS_E_WARNING_ALERT_RECEIVED
23 || ret
== GNUTLS_E_FATAL_ALERT_RECEIVED
)
25 last_alert
= gnutls_alert_get (session
);
27 /* The check for renegotiation is only useful if we are
28 * a server, and we had requested a rehandshake.
30 if (last_alert
== GNUTLS_A_NO_RENEGOTIATION
&&
31 ret
== GNUTLS_E_WARNING_ALERT_RECEIVED
)
32 printf ("* Received NO_RENEGOTIATION alert. "
33 "Client Does not support renegotiation.\n");
35 printf ("* Received alert '%d': %s.\n", last_alert
,
36 gnutls_alert_get_name (last_alert
));