1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

dirmngr: Print certificates on failed TLS verification.

* dirmngr/ks-engine-hkp.c (cert_log_cb): New.
(send_request): Set callback.
--

We use the KSBA functions here because we have them anyway in Dirmngr.
This commit is contained in:
Werner Koch 2014-05-19 09:48:42 +02:00
parent 45f15b2d76
commit 9e1c99f800

View File

@ -873,6 +873,40 @@ ks_hkp_housekeeping (time_t curtime)
} }
/* Callback to print infos about the TLS certificates. */
static void
cert_log_cb (http_session_t sess, gpg_error_t err,
const char *hostname, const void **certs, size_t *certlens)
{
ksba_cert_t cert;
size_t n;
(void)sess;
if (!err)
return; /* No error - no need to log anything */
log_debug ("expected hostname: %s\n", hostname);
for (n=0; certs[n]; n++)
{
err = ksba_cert_new (&cert);
if (!err)
err = ksba_cert_init_from_mem (cert, certs[n], certlens[n]);
if (err)
log_error ("error parsing cert for logging: %s\n", gpg_strerror (err));
else
{
char textbuf[20];
snprintf (textbuf, sizeof textbuf, "server[%u]", (unsigned int)n);
dump_cert (textbuf, cert);
}
ksba_cert_release (cert);
}
}
/* Send an HTTP request. On success returns an estream object at /* Send an HTTP request. On success returns an estream object at
R_FP. HOSTPORTSTR is only used for diagnostics. If HTTPHOST is R_FP. HOSTPORTSTR is only used for diagnostics. If HTTPHOST is
not NULL it will be used as HTTP "Host" header. If POST_CB is not not NULL it will be used as HTTP "Host" header. If POST_CB is not
@ -896,6 +930,7 @@ send_request (ctrl_t ctrl, const char *request, const char *hostportstr,
err = http_session_new (&session, NULL); err = http_session_new (&session, NULL);
if (err) if (err)
goto leave; goto leave;
http_session_set_log_cb (session, cert_log_cb);
once_more: once_more:
err = http_open (&http, err = http_open (&http,