[Misc] Move fix for ‘mm-view-pkcs7-verify’ to init.el
This commit is contained in:
parent
9e8649247d
commit
56d085d4f1
34
gnus.el
34
gnus.el
|
@ -412,40 +412,6 @@ METHOD specifies the encrypt method used. Can be either
|
||||||
(add-hook 'gnus-message-setup-hook
|
(add-hook 'gnus-message-setup-hook
|
||||||
#'db/signencrypt-message-when-possible)
|
#'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
|
;;; Custom commands
|
||||||
|
|
||||||
|
|
35
init.el
35
init.el
|
@ -1224,6 +1224,41 @@
|
||||||
(bbdb-initialize 'gnus 'message)
|
(bbdb-initialize 'gnus 'message)
|
||||||
(bbdb-mua-auto-update-init '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
|
;; * Crypto
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue