GNU bug report logs - #40118
27.0.90; Signing emails with gpg

Previous Next

Package: emacs;

Reported by: Sharon Kimble <boudiccas <at> skimble.plus.com>

Date: Wed, 18 Mar 2020 14:52:01 UTC

Severity: normal

Tags: fixed

Found in version 27.0.90

Fixed in versions 27.2, 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, stepnem <at> gmail.com, 40118 <at> debbugs.gnu.org
Subject: bug#40118: 27.0.90; Signing emails with gpg
Date: Fri, 17 Apr 2020 17:11:53 +0200
Since itʼs Friday afternoon, what Eli really wants to do is make
another decision on whether to let something into emacs-27 just before
the next rc. How about this? If itʼs not OK Iʼll just adjust the error
message, if it is OK Iʼll write a NEWS entry.

diff --git a/lisp/gnus/mml-sec.el b/lisp/gnus/mml-sec.el
index 740e1d2b72..8abe83b937 100644
--- a/lisp/gnus/mml-sec.el
+++ b/lisp/gnus/mml-sec.el
@@ -937,6 +937,47 @@ mml-secure-epg-encrypt
        (signal (car error) (cdr error))))
     cipher))
 
+(defun mml-secure-sender-sign-query (protocol sender)
+  "Query whether to use SENDER to sign when using PROTOCOL.
+PROTOCOL will be `OpenPGP' or `CMS' (smime).
+This can also save the resulting value of
+`mml-secure-smime-sign-with-sender' or
+`mml-secure-openpgp-sign-with-sender' via Customize.
+Returns non-nil if the user has chosen to use SENDER."
+  (let ((buffer (get-buffer-create "*MML sender signing options*"))
+        (options '((?a "always" "Sign using this sender now and sign with message sender in future.")
+                   (?s "session only" "Sign using this sender now, and sign with message sender for this session only.")
+                   (?n "no" "Do not sign this message (and error out)")))
+        answer done val)
+    (save-window-excursion
+      (pop-to-buffer buffer)
+      (erase-buffer)
+      (insert (format "No %s signing key was found for this message.\nThe sender of this message is \"%s\".\nWould you like to attempt looking up a signing key based on it?"
+                      (if (eq protocol 'OpenPGP)
+                          "openpgp" "smime")
+                      sender))
+      (while (not done)
+        (setq answer (read-multiple-choice "Sign this message using the sender?" options))
+        (cl-case (car answer)
+          (?a
+           (if (eq protocol 'OpenPGP)
+               (progn
+                 (setq mml-secure-openpgp-sign-with-sender t)
+                 (customize-save-variable 'mml-secure-openpgp-sign-with-sender t))
+             (setq mml-secure-smime-sign-with-sender t)
+             (customize-save-variable 'mml-secure-smime-sign-with-sender t))
+           (setq done t
+                 val t))
+          (?s
+           (if (eq protocol 'OpenPGP)
+               (setq mml-secure-openpgp-sign-with-sender t)
+             (setq mml-secure-smime-sign-with-sender t))
+           (setq done t
+                 val t))
+          (?n
+           (setq done t)))))
+    val))
+
 (defun mml-secure-epg-sign (protocol mode)
   ;; Based on code appearing inside mml2015-epg-sign.
   (let* ((context (epg-make-context protocol))
@@ -945,15 +986,21 @@ mml-secure-epg-sign
 	 (signers (mml-secure-signers context signer-names))
 	 signature micalg)
     (unless signers
-      (let ((maybe-msg
-             (if mml-secure-smime-sign-with-sender
-                 "."
-               "; try setting `mml-secure-smime-sign-with-sender'.")))
-        ;; If `mml-secure-smime-sign-with-sender' is already non-nil
-        ;; then there's no point advising the user to examine it.  If
-        ;; there are any other variables worth examining, please
-        ;; improve this error message by having it mention them.
-        (error "Couldn't find any signer names%s" maybe-msg)))
+      (if (mml-secure-sender-sign-query protocol sender)
+          (setq signer-names (mml-secure-signer-names protocol sender)
+                signers (mml-secure-signers context signer-names)))
+      (unless signers
+        (let ((maybe-msg
+               (if (or mml-secure-smime-sign-with-sender
+                       mml-secure-openpgp-sign-with-sender)
+                   "."
+                 "; try setting `mml-secure-smime-sign-with-sender' or 'mml-secure-openpgp-sign-with-sender'.")))
+          ;; If `mml-secure-smime-sign-with-sender' or
+          ;; `mml-secure-openpgp-sign-with-sender' are already non-nil
+          ;; then there's no point advising the user to examine them.
+          ;; If there are any other variables worth examining, please
+          ;; improve this error message by having it mention them.
+          (error "Couldn't find any signer names%s" maybe-msg))))
     (when (eq 'OpenPGP protocol)
       (setf (epg-context-armor context) t)
       (setf (epg-context-textmode context) t)




This bug report was last modified 4 years and 236 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.