From 08fbe91dfebf023bb45f1485fb432e9118ef5abb Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 26 Sep 2019 16:32:13 +0200 Subject: [PATCH] Make mm-view-pkcs7-verify use epg if requested * lisp/gnus/mm-view.el (mm-view-pkcs7-verify): Respect mml-smime-use (bug#18393). --- lisp/gnus/mm-view.el | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) 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") -- 2.39.2