From: Lars Ingebrigtsen Date: Thu, 26 Sep 2019 14:24:29 +0000 (+0200) Subject: Make it possible to view S/MIME verified emails X-Git-Tag: emacs-27.0.90~1426 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84ef1ea8b524f8998fc8674b99cf8069e38dce4f;p=emacs.git Make it possible to view S/MIME verified emails * lisp/gnus/mm-decode.el (mm-possibly-verify-or-decrypt): When dissecting the result, we need a header (bug#18393). * lisp/gnus/mm-view.el (mm-view-pkcs7-verify): Insert the verified string. * lisp/gnus/smime.el (smime-verify-region): Return the verified string. --- diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 673098bcb68..42bf5f8081c 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -1672,6 +1672,8 @@ If RECURSIVE, search recursively." (t (y-or-n-p (format "Decrypt (S/MIME) part? ")))) (mm-view-pkcs7 parts from)) + (goto-char (point-min)) + (insert "Content-type: text/plain\n\n") (setq parts (mm-dissect-buffer t))))) ((equal subtype "signed") (unless (and (setq protocol @@ -1739,6 +1741,7 @@ If RECURSIVE, search recursively." (mm-set-handle-multipart-parameter mm-security-handle 'gnus-details (format "Unknown encrypt protocol (%s)" protocol))))))) + ;; Check the results (which are now in `parts'). (let ((info (get-text-property 0 'gnus-info (car mm-security-handle)))) (if (or (not info) (equal info "") diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index 02d99200a35..b66d152fa63 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -588,18 +588,9 @@ If MODE is not set, try to find mode automatically." (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)))) - (goto-char (point-min)) - (mm-insert-part handle) - (if (search-forward "Content-Type: " nil t) - (delete-region (point-min) (match-beginning 0))) - (goto-char (point-max)) - (if (re-search-backward "--\r?\n?" nil t) - (delete-region (match-end 0) (point-max))) - (unless verified + (if verified + (insert verified) (insert-buffer-substring smime-details-buffer))) - (goto-char (point-min)) - (while (search-forward "\r\n" nil t) - (replace-match "\n")) t) (autoload 'epg-decrypt-string "epg") diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el index b7ec033603f..d8131c60dbe 100644 --- a/lisp/gnus/smime.el +++ b/lisp/gnus/smime.el @@ -371,16 +371,21 @@ Any details (stdout and stderr) are left in the buffer specified by (expand-file-name smime-CA-file))) (if smime-CA-directory (list "-CApath" - (expand-file-name smime-CA-directory)))))) + (expand-file-name smime-CA-directory))))) + (input-buffer (current-buffer))) (unless CAs (error "No CA configured")) (if smime-crl-check (cl-pushnew smime-crl-check CAs :test #'equal)) - (if (apply 'smime-call-openssl-region b e (list smime-details-buffer t) - "smime" "-verify" "-out" "/dev/null" CAs) - t - (insert-buffer-substring smime-details-buffer) - nil))) + (with-temp-buffer + (let ((result-buffer (current-buffer))) + (with-current-buffer input-buffer + (if (apply 'smime-call-openssl-region b e (list result-buffer + smime-details-buffer) + "smime" "-verify" "-out" "-" CAs) + (with-current-buffer result-buffer + (buffer-string)) + nil)))))) (defun smime-noverify-region (b e) "Verify integrity of S/MIME message in region between B and E.