Subject: bug#26298: 26.0.50; Gnus fails to sign mail with PGP

From: Noam Postavsky <[email-masked]>
Date: Sun, 28 Jan 2018 16:23:02 -0500

Toon Claes <[email-masked]> writes:

> On Tue, Aug 15, 2017 at 1:54 AM, Toon Claes <[email-masked]> wrote:
>> [email-masked] writes:
>>
>>> Does the patch at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23619#14
>>> help?
>>
>> Well, actually it does help.
>
> One thing though, with this patch, if I enter the incorrect passphrase,
> it gives me an error:
>
>     Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
>       mml2015-epg-sign((part (sign . "pgpmime") (tag-location . 803) (contents . "<redacted>")))
>       mml2015-sign((part (sign . "pgpmime") (tag-location . 803) (contents . "<redacted>")))

I can't reproduce the original bug, but this I can, although with
mml1991 (not clear to me how this get's chosen).  I think it's just a
matter of making the error a bit clearer, e.g.:

--- i/lisp/gnus/mml1991.el
+++ w/lisp/gnus/mml1991.el
@@ -277,6 +277,8 @@ mml1991-epg-sign
 	(mm-decode-content-transfer-encoding cte)))
     (let* ((pair (mml-secure-epg-sign 'OpenPGP 'clear))
 	   (signature (car pair)))
+      (unless (stringp signature)
+        (error "Signature failed"))
       (delete-region (point-min) (point-max))
       (insert
        (with-temp-buffer
diff --git i/lisp/gnus/mml2015.el w/lisp/gnus/mml2015.el
index b220a96098..6baae80309 100644
--- i/lisp/gnus/mml2015.el
+++ w/lisp/gnus/mml2015.el
@@ -958,6 +958,8 @@ mml2015-epg-sign
     (let* ((pair (mml-secure-epg-sign 'OpenPGP t))
 	   (signature (car pair))
 	   (micalg (cdr pair)))
+      (unless (stringp signature)
+        (error "Signature failed"))
       (goto-char (point-min))
       (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
 		      boundary))

> When I try again instantly, it does not ask me for the passphrase and
> just pops up the same error. When I wait for, I think, about 10 seconds
> to retry, it asks for a passphrase again.

Hmm, I can't reproduce this one, I guess it's related to gpg version (I
have 2.1.18) and how the caching works.