]> git.eshelyaron.com Git - emacs.git/commitdiff
Make mm-view-pkcs7-verify use epg if requested
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Sep 2019 14:32:13 +0000 (16:32 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Sep 2019 14:32:13 +0000 (16:32 +0200)
* lisp/gnus/mm-view.el (mm-view-pkcs7-verify): Respect
mml-smime-use (bug#18393).

lisp/gnus/mm-view.el

index b66d152fa63877b75b643f066c324833e9112ce6..559ec7a669241cf6deb9f2119c079bc607b04ba7 100644 (file)
@@ -583,15 +583,23 @@ If MODE is not set, try to find mode automatically."
 
 (defun mm-view-pkcs7-verify (handle)
   (let ((verified nil))
-    (with-temp-buffer
-      (insert "MIME-Version: 1.0\n")
-      (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
-      (insert-buffer-substring (mm-handle-buffer handle))
-      (setq verified (smime-verify-region (point-min) (point-max))))
-    (if verified
-       (insert verified)
-      (insert-buffer-substring smime-details-buffer)))
-  t)
+    (if (eq mml-smime-use 'epg)
+       ;; Use EPG/gpgsm
+       (insert
+        (with-temp-buffer
+          (insert-buffer-substring (mm-handle-buffer handle))
+          (goto-char (point-min))
+          (let ((part (base64-decode-string (buffer-string))))
+            (epg-verify-string (epg-make-context 'CMS) part))))
+      (with-temp-buffer
+       (insert "MIME-Version: 1.0\n")
+       (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
+       (insert-buffer-substring (mm-handle-buffer handle))
+       (setq verified (smime-verify-region (point-min) (point-max))))
+      (if verified
+         (insert verified)
+       (insert-buffer-substring smime-details-buffer)))
+    t))
 
 (autoload 'epg-decrypt-string "epg")