crypt-gpgme.c |  65 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 44 insertions(+), 21 deletions(-)


# HG changeset patch
# User Michael Elkins <[email protected]>
# Date 1380909842 0
# Branch HEAD
# Node ID 04c0cf885460b4a26a4743c45a1bd7f2847c7e91
# Parent  a0f5390e89d12f30ebff4db82b0ce2010a1a83dc
Display the KeyID when the pubkey is not found in the user's keyring during 
signature verification.

closes #3654

diff --git a/crypt-gpgme.c b/crypt-gpgme.c
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -1263,21 +1263,31 @@
 
   state_attach_puts (msg, s);
   state_attach_puts (" ", s);
-  for (uids = key->uids; uids; uids = uids->next)
+  /* key is NULL when not present in the user's keyring */
+  if (key)
   {
-    if (uids->revoked)
-      continue;
-    if (aka)
+    for (uids = key->uids; uids; uids = uids->next)
     {
-      msglen = mutt_strlen (msg) - 4;
-      for (i = 0; i < msglen; i++)
-        state_attach_puts(" ", s);
-      state_attach_puts(_("aka: "), s);
+      if (uids->revoked)
+       continue;
+      if (aka)
+      {
+       msglen = mutt_strlen (msg) - 4;
+       for (i = 0; i < msglen; i++)
+         state_attach_puts(" ", s);
+       state_attach_puts(_("aka: "), s);
+      }
+      state_attach_puts (uids->uid, s);
+      state_attach_puts ("\n", s);
+
+      aka = 1;
     }
-    state_attach_puts (uids->uid, s);
+  }
+  else
+  {
+    state_attach_puts (_("KeyID "), s);
+    state_attach_puts (sig->fpr, s);
     state_attach_puts ("\n", s);
-    
-    aka = 1;
   }
 
   msglen = mutt_strlen (msg) - 8;
@@ -1330,23 +1340,32 @@
       if (gpg_err_code (sig->status) != GPG_ERR_NO_ERROR)
        anybad = 1;
 
-      err = gpgme_get_key (ctx, fpr, &key, 0); /* secret key?  */
-      if (! err)
+      if (gpg_err_code (sig->status) != GPG_ERR_NO_PUBKEY)
+      {
+       err = gpgme_get_key (ctx, fpr, &key, 0); /* secret key?  */
+       if (! err)
        {
          if (! signature_key)
            signature_key = key;
        }
+       else
+       {
+         key = NULL; /* Old gpgme versions did not set KEY to NULL on
+                        error.   Do it here to avoid a double free. */
+       }
+      }
       else
-       {
-          key = NULL; /* Old gpgme versions did not set KEY to NULL on
-                         error.   Do it here to avoid a double free. */
-       }
+      {
+       /* pubkey not present */
+      }
 
       if (!s || !s->fpout || !(s->flags & M_DISPLAY))
        ; /* No state information so no way to print anything. */
       else if (err)
        {
-          state_attach_puts (_("Error getting key information: "), s);
+          state_attach_puts (_("Error getting key information for KeyID "), s);
+         state_attach_puts ( fpr, s );
+          state_attach_puts (_(": "), s);
           state_attach_puts ( gpgme_strerror (err), s );
           state_attach_puts ("\n", s);
           anybad = 1;
@@ -1377,9 +1396,13 @@
       else /* can't decide (yellow) */
       {
         print_smime_keyinfo (_("Problem signature from:"), sig, key, s);
-        state_attach_puts (_("               expires: "), s);
-        print_time (sig->exp_timestamp, s);
-        state_attach_puts ("\n", s);
+       /* 0 indicates no expiration */
+       if (sig->exp_timestamp)
+       {
+         state_attach_puts (_("               expires: "), s);
+         print_time (sig->exp_timestamp, s);
+         state_attach_puts ("\n", s);
+       }
        show_sig_summary (sum, ctx, key, idx, s, sig);
         anywarn = 1;
       }

Reply via email to