From: Lars Ingebrigtsen Date: Thu, 26 Sep 2019 14:32:13 +0000 (+0200) Subject: Make mm-view-pkcs7-verify use epg if requested X-Git-Tag: emacs-27.0.90~1425 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08fbe91dfebf023bb45f1485fb432e9118ef5abb;p=emacs.git Make mm-view-pkcs7-verify use epg if requested * lisp/gnus/mm-view.el (mm-view-pkcs7-verify): Respect mml-smime-use (bug#18393). --- diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index b66d152fa63..559ec7a6692 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -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")