[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

enabling automatic PGP signing (was: expire-alist syntax)



At Mon, 03 May 2010 22:45:13 +0100, Eric S Fraga <ucecesf@ucl.ac.uk> wrote:
Subject: Re: expire-alist syntax
> 
> I notice that you have your emails digitally signed.  I've tried
> getting this to work automatically in WL but have failed so far.
> Would you be able to give me any hints on configuration issues?  I'm
> using emacs 23 with wl-beta from Debian.

I dunno how others are doing it, but here are what I believe to be the
relevant bits from my ~/.wl:

;; XXX this doesn't quite work right to turn on automatic signing globally...
;;
;(setq mime-edit-pgp-processing '(sign))

(setq mime-setup-enable-pgp t)		; it is the default
;(setq pgg-default-scheme 'pgp5)		; for composing
;(setq pgg-scheme 'pgp5)			; for verify/decrypt
(setq pgg-default-scheme 'gpg)		; for composing
(setq pgg-scheme 'gpg)			; for verify/decrypt
(setq pgg-cache-passphrase t)		; it is the default
(setq pgg-passphrase-cache-expiry 14400); 4 hrs
;(setq pgg-read-passphrase 'read-passwd)	; it is the default?
(setq pgg-read-passphrase 'read-string)	; XXX for debugging
(setq pgg-insert-url-function  (function pgg-insert-url-with-program))
;; NetBSD's ftp(1) "Does The Right Thing(tm)"!
(setq pgg-insert-url-program "ftp")
(setq pgg-insert-url-extra-arguments '("-o" "-"))

;; add a (pgp-sign . BOOL)
(unless (assq 'pgp-sign wl-draft-config-sub-func-alist)
  (wl-append wl-draft-config-sub-func-alist
	     '((pgp-sign . mime-edit-set-sign))))

;; add a (pgp-encrypt . BOOL)
(unless (assq 'pgp-encrypt wl-draft-config-sub-func-alist)
  (wl-append wl-draft-config-sub-func-alist
	     '((pgp-encrypt . mime-edit-set-encrypt))))


NOTE: I don't sign my posts to this list because I'm using a different
local-part in my address which foils key lookup by e-mail address, so I
turn it off for replies to the list with the following snippet, or
default it to on for every other draft message:

(setq wl-draft-config-alist
      '(
	;; mailing list:  wl-en
	((or (string-match "^%inbox/Lists-IN/wl-en-l"
			   wl-draft-parent-folder)
	     (string-match "^%inbox/list-archive/wl-en@"
			   wl-draft-parent-folder))
	 (pgp-sign . nil)
         ("From" . "\"Greg A. Woods\" <woods-wl-en-l@planix.com>")
	 ("To" . "WanderLust Users Mailing List (English) <wl-en@lists.airs.net>")
	 ("Reply-To" . "WanderLust Users Mailing List (English) <wl-en@lists.airs.net>")
	 ("Organization" . "Planix, Inc."))
	 ;;[[....]]
	; defaults for everything
	((or t)
	 (pgp-sign . t)
	 mime-edit-insert-signature)))


ALSO NOTE:  Because PGP treat certain whitespace specially, such as at
the end of a line, it is critical to ensure your messages are properly
encoded so as to avoid any problems in this area.  As it happens MIME's
quoted-printable encoding is perfect for PGP, so I also automatically
insert the following MIME encoding tag in my messages (i.e. so that the
body of the message, before the inserted signature, starts with the MIME
tag "[[text/plain][quoted-printable]]"):

;; Unfortunately this `defadvice' is not quite sufficient on its own.
;;
;; XXX The only work-around I know for now is to mark the entire body of the
;; message as as region just before I'm ready to send and then invoke
;;`mime-encode-region' with the now-default value of "quoted-printable".
;;
;;	C-t M-<SPACE> M-> M-x mime-encode-region <RETURN> <RETURN>
;;
;; It doesn't seem like WL/SEMI/FLIM implements quoted-printable encoding
;; properly, or maybe even not at all (i.e. doing this seems to be a no-op, as
;; will be evident from this message).
;; 
;; I do see the MIME tag as "[[text/plain][quoted-printable]]", and this
;; message will have a "Content-Transfer-Encoding: quoted-printable"
;; header, but there will be no such encoding performed before it is sent.
;;
;; It may be that `mime-edit-translate-body' doesn't do any encoding work, but
;; if not, how to make it do so and yet avoid encoding files, etc. that have
;; been inserted with their encoding already done?  It probably doesn't do any
;; encoding because it assumes the encoding was already done when the file was
;; inserted, but this is not true for `mime-edit-insert-text' or the equivalent
;; since that's likely just text typed by the user.
;;
;; Maybe when we're about to send a message we should first run through all the
;; MIME parts (instead of the following) and transform any [[text/*]] tags
;; without a specified encoding to add the [quoted-printable] encoding and of
;; course then do the necessary quoted-printable encoding automatically as well
;; at that time.  Optionally we could do this only when we're using PGG to sign
;; a message, but really all text will be more robust through e-mail if it is
;; encoded somehow, and quoted-printable is the least intrusive, only showing
;; its ugly head if it is absolutely necessary.
;;
(defadvice mime-edit-insert-signature (after my-mime-edit-signature-set-qp-encoding activate)
  "Add quoted-printable encoding to the MIME tag for the message."
  (mime-edit-define-encoding "quoted-printable"))

;; XXX this function is a copy of the original done simply to change the
;; default value for the encoding to be quoted-printable instead of base64
;;
(defun mime-encode-region (start end encoding)
  "Encode region START to END of current buffer using ENCODING.
ENCODING must be string."
  (interactive
   (list (region-beginning)(region-end)
	 (completing-read "Encoding: "
			  (mime-encoding-alist)
			  nil t "quoted-printable")))
  (funcall (mel-find-function 'mime-encode-region encoding) start end))



I posted about this last issue way back in 2005, but I haven't found a
decent complete fix yet.

-- 
						Greg A. Woods
						Planix, Inc.

<woods@planix.com>       +1 416 218 0099        http://www.planix.com/