gnutls_alert_get_strname - Linux
Overview
gnutls_alert_get_strname retrieves the string representation of a TLS/SSL alert.
Syntax
int gnutls_alert_get_strname(unsigned int alert, char *buf, size_t buflen);
Options/Flags
| Option | Description | Default Value |
|—|—|—|
| alert
| The alert number. | N/A |
| buf
| A buffer to store the string representation. | N/A |
| buflen
| The size of the buffer. | N/A |
Examples
#include <gnutls/gnutls.h>
int main() {
char buf[256];
gnutls_alert_get_strname(GNUTLS_A_HANDSHAKE_FAILURE, buf, sizeof(buf));
printf("Alert: %s\n", buf);
return 0;
}
Common Issues
If the buffer is too small to hold the string representation, the function will return GNUTLS_E_SHORT_MEMORY_BUFFER.
Integration
gnutls_alert_get_strname can be used with other GnuTLS functions to handle TLS/SSL alerts. For example, it can be used to log the reason for an alert being sent or received.
Related Commands
- gnutls_alert_get_description
- gnutls_alert_get_level