]> git.eshelyaron.com Git - emacs.git/commitdiff
Make it possible to view S/MIME verified emails
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Sep 2019 14:24:29 +0000 (16:24 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Sep 2019 14:24:29 +0000 (16:24 +0200)
* 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.

lisp/gnus/mm-decode.el
lisp/gnus/mm-view.el
lisp/gnus/smime.el

index 673098bcb683c761c43544e28525c17fd3e3cdda..42bf5f8081cc9ae5321243fb35155831020c3d77 100644 (file)
@@ -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 "")
index 02d99200a35cdf28b8db8939c0c53996054417a6..b66d152fa63877b75b643f066c324833e9112ce6 100644 (file)
@@ -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")
index b7ec033603f0f0fd8f9cbedb60eb9dfd8317698e..d8131c60dbe3e93d968743f70ce5c5e0d5f66c9d 100644 (file)
@@ -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.