[Misc] Move fix for ‘mm-view-pkcs7-verify’ to init.el

This commit is contained in:
Daniel - 2019-01-27 13:32:00 +01:00
parent 9e8649247d
commit 56d085d4f1
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
2 changed files with 35 additions and 34 deletions

34
gnus.el
View File

@ -412,40 +412,6 @@ METHOD specifies the encrypt method used. Can be either
(add-hook 'gnus-message-setup-hook
#'db/signencrypt-message-when-possible)
;; Fix: mm-view does not seem to support verifying S/MIME messages using gpgsm,
;; so we add a simple fix here
(defun mm-view-pkcs7-verify (handle)
(let ((verified nil))
(with-temp-buffer
(if (eq mml-smime-use 'epg)
;; Use gpgsm
(progn
(insert-buffer-substring (mm-handle-buffer handle))
(setq verified (epg-verify-string (epg-make-context 'CMS)
(base64-decode-string (buffer-string)))))
;; FIXME: insert valid signature
;; use openssl
(progn
(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))))))
(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
(insert-buffer-substring smime-details-buffer)))
(goto-char (point-min))
(while (search-forward "\r\n" nil t)
(replace-match "\n"))
t)
;;; Custom commands

35
init.el
View File

@ -1224,6 +1224,41 @@
(bbdb-initialize 'gnus 'message)
(bbdb-mua-auto-update-init 'message)))
(use-package mm-view
:config (progn
;; Fix: mm-view does not seem to support verifying S/MIME messages
;; using gpgsm, so we add a simple fix here
(defun mm-view-pkcs7-verify (handle)
(let ((verified nil))
(with-temp-buffer
(if (eq mml-smime-use 'epg)
;; Use gpgsm
(progn
(insert-buffer-substring (mm-handle-buffer handle))
(setq verified (epg-verify-string (epg-make-context 'CMS)
(base64-decode-string (buffer-string)))))
;; FIXME: insert valid signature
;; use openssl
(progn
(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))))))
(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
(insert-buffer-substring smime-details-buffer)))
(goto-char (point-min))
(while (search-forward "\r\n" nil t)
(replace-match "\n"))
t)))
;; * Crypto