From 5ed5b2e5685fb06b6e73f3c468962ea7758029b0 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 24 Nov 2016 09:49:13 +0100 Subject: errors.h: added _gnutls_cert_log This log function allows to easily log the name of a certificate. --- lib/errors.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 #include +#include #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) -- cgit v1.2.1