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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-06-04 09:23:27 +02:00
parent 537fbe13af
commit 9bf650db02
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 5 additions and 10 deletions

View File

@ -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