From 9bf650db022b6b65bbfa74c311cdc3e6b73d3b44 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 4 Jun 2019 09:23:27 +0200 Subject: sm: Print a better diagnostic for encryption certificate selection. * sm/certlist.c (gpgsm_add_to_certlist): Add diagnostic and fold two similar branches. -- Without this patch gpgsm printed: gpgsm[23045]: DBG: chan_6 <- RECIPIENT edward.tester@demo.gnupg.com gpgsm[23045]: certificate is not usable for encryption gpgsm[23045]: certificate is good with this patch a gpgsm[23045]: looking for another certificate is inserted into the log. Signed-off-by: Werner Koch --- sm/certlist.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sm/certlist.c b/sm/certlist.c index 0847c169b..b3d113bfd 100644 --- a/sm/certlist.c +++ b/sm/certlist.c @@ -352,19 +352,14 @@ gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret, { /* There might be another certificate with the correct usage, so we try again */ - if (!wrong_usage) - { /* save the first match */ - wrong_usage = rc; - ksba_cert_release (cert); - cert = NULL; - goto get_next; - } - else if (same_subject_issuer (first_subject, first_issuer, - cert)) + if (!wrong_usage + || same_subject_issuer (first_subject, first_issuer,cert)) { - wrong_usage = rc; + if (!wrong_usage) + wrong_usage = rc; /* save error of the first match */ ksba_cert_release (cert); cert = NULL; + log_info (_("looking for another certificate\n")); goto get_next; } else -- cgit v1.2.3