summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-24 09:49:13 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-25 10:37:07 +0100
commit5ed5b2e5685fb06b6e73f3c468962ea7758029b0 (patch)
treea4a79c774a4d1802dff6d47390bd653a4c69456b
parent208a2e1649ad9e9ef19e0a48c928b07ebffeed90 (diff)
downloadgnutls-5ed5b2e5685fb06b6e73f3c468962ea7758029b0.tar.gz
errors.h: added _gnutls_cert_log
This log function allows to easily log the name of a certificate.
-rw-r--r--lib/errors.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/errors.h b/lib/errors.h
index e14a4df586..78b89123e4 100644
--- a/lib/errors.h
+++ b/lib/errors.h
@@ -26,6 +26,7 @@
#include "gnutls_int.h"
#include <global.h>
#include <mpi.h>
+#include <gnutls/x509.h>
#define GNUTLS_E_INT_RET_0 -1251
#define GNUTLS_E_INT_CHECK_AGAIN -1252
@@ -58,6 +59,18 @@ void _gnutls_audit_log(gnutls_session_t, const char *fmt, ...)
void _gnutls_mpi_log(const char *prefix, bigint_t a);
+#define _gnutls_cert_log(str, cert) \
+ do { \
+ if (unlikely(_gnutls_log_level >= 3)) { \
+ gnutls_datum_t _cl_out; int _cl_ret; \
+ _cl_ret = gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_ONELINE, &_cl_out); \
+ if (_cl_ret >= 0) { \
+ _gnutls_log( 3, "%s: %s\n", str, _cl_out.data); \
+ gnutls_free(_cl_out.data); \
+ } \
+ } \
+ } while(0)
+
#ifdef C99_MACROS
#define LEVEL(l, ...) do { if (unlikely(_gnutls_log_level >= l)) \
_gnutls_log( l, __VA_ARGS__); } while(0)