diff options
| author | Lars Ingebrigtsen | 2019-09-26 16:24:29 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-09-26 16:24:29 +0200 |
| commit | 84ef1ea8b524f8998fc8674b99cf8069e38dce4f (patch) | |
| tree | bab670711c6482b4b3771b6e092daa809eb97e90 | |
| parent | 8e46cf4ba8c1992f52059cf530f5919f9fc33305 (diff) | |
| download | emacs-84ef1ea8b524f8998fc8674b99cf8069e38dce4f.tar.gz emacs-84ef1ea8b524f8998fc8674b99cf8069e38dce4f.zip | |
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.
| -rw-r--r-- | lisp/gnus/mm-decode.el | 3 | ||||
| -rw-r--r-- | lisp/gnus/mm-view.el | 13 | ||||
| -rw-r--r-- | lisp/gnus/smime.el | 17 |
3 files changed, 16 insertions, 17 deletions
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." | |||
| 1672 | (t (y-or-n-p | 1672 | (t (y-or-n-p |
| 1673 | (format "Decrypt (S/MIME) part? ")))) | 1673 | (format "Decrypt (S/MIME) part? ")))) |
| 1674 | (mm-view-pkcs7 parts from)) | 1674 | (mm-view-pkcs7 parts from)) |
| 1675 | (goto-char (point-min)) | ||
| 1676 | (insert "Content-type: text/plain\n\n") | ||
| 1675 | (setq parts (mm-dissect-buffer t))))) | 1677 | (setq parts (mm-dissect-buffer t))))) |
| 1676 | ((equal subtype "signed") | 1678 | ((equal subtype "signed") |
| 1677 | (unless (and (setq protocol | 1679 | (unless (and (setq protocol |
| @@ -1739,6 +1741,7 @@ If RECURSIVE, search recursively." | |||
| 1739 | (mm-set-handle-multipart-parameter | 1741 | (mm-set-handle-multipart-parameter |
| 1740 | mm-security-handle 'gnus-details | 1742 | mm-security-handle 'gnus-details |
| 1741 | (format "Unknown encrypt protocol (%s)" protocol))))))) | 1743 | (format "Unknown encrypt protocol (%s)" protocol))))))) |
| 1744 | ;; Check the results (which are now in `parts'). | ||
| 1742 | (let ((info (get-text-property 0 'gnus-info (car mm-security-handle)))) | 1745 | (let ((info (get-text-property 0 'gnus-info (car mm-security-handle)))) |
| 1743 | (if (or (not info) | 1746 | (if (or (not info) |
| 1744 | (equal info "") | 1747 | (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." | |||
| 588 | (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m") | 588 | (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m") |
| 589 | (insert-buffer-substring (mm-handle-buffer handle)) | 589 | (insert-buffer-substring (mm-handle-buffer handle)) |
| 590 | (setq verified (smime-verify-region (point-min) (point-max)))) | 590 | (setq verified (smime-verify-region (point-min) (point-max)))) |
| 591 | (goto-char (point-min)) | 591 | (if verified |
| 592 | (mm-insert-part handle) | 592 | (insert verified) |
| 593 | (if (search-forward "Content-Type: " nil t) | ||
| 594 | (delete-region (point-min) (match-beginning 0))) | ||
| 595 | (goto-char (point-max)) | ||
| 596 | (if (re-search-backward "--\r?\n?" nil t) | ||
| 597 | (delete-region (match-end 0) (point-max))) | ||
| 598 | (unless verified | ||
| 599 | (insert-buffer-substring smime-details-buffer))) | 593 | (insert-buffer-substring smime-details-buffer))) |
| 600 | (goto-char (point-min)) | ||
| 601 | (while (search-forward "\r\n" nil t) | ||
| 602 | (replace-match "\n")) | ||
| 603 | t) | 594 | t) |
| 604 | 595 | ||
| 605 | (autoload 'epg-decrypt-string "epg") | 596 | (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 | |||
| 371 | (expand-file-name smime-CA-file))) | 371 | (expand-file-name smime-CA-file))) |
| 372 | (if smime-CA-directory | 372 | (if smime-CA-directory |
| 373 | (list "-CApath" | 373 | (list "-CApath" |
| 374 | (expand-file-name smime-CA-directory)))))) | 374 | (expand-file-name smime-CA-directory))))) |
| 375 | (input-buffer (current-buffer))) | ||
| 375 | (unless CAs | 376 | (unless CAs |
| 376 | (error "No CA configured")) | 377 | (error "No CA configured")) |
| 377 | (if smime-crl-check | 378 | (if smime-crl-check |
| 378 | (cl-pushnew smime-crl-check CAs :test #'equal)) | 379 | (cl-pushnew smime-crl-check CAs :test #'equal)) |
| 379 | (if (apply 'smime-call-openssl-region b e (list smime-details-buffer t) | 380 | (with-temp-buffer |
| 380 | "smime" "-verify" "-out" "/dev/null" CAs) | 381 | (let ((result-buffer (current-buffer))) |
| 381 | t | 382 | (with-current-buffer input-buffer |
| 382 | (insert-buffer-substring smime-details-buffer) | 383 | (if (apply 'smime-call-openssl-region b e (list result-buffer |
| 383 | nil))) | 384 | smime-details-buffer) |
| 385 | "smime" "-verify" "-out" "-" CAs) | ||
| 386 | (with-current-buffer result-buffer | ||
| 387 | (buffer-string)) | ||
| 388 | nil)))))) | ||
| 384 | 389 | ||
| 385 | (defun smime-noverify-region (b e) | 390 | (defun smime-noverify-region (b e) |
| 386 | "Verify integrity of S/MIME message in region between B and E. | 391 | "Verify integrity of S/MIME message in region between B and E. |