Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Automatically sign/encrypt messages
@ 2004-01-29 17:31 Klaus Uhl
  2004-01-30 19:06 ` Ted Zlatanov
  2004-02-04 16:33 ` Eric Simon
  0 siblings, 2 replies; 7+ messages in thread
From: Klaus Uhl @ 2004-01-29 17:31 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

Hi,

I am not sure if this of interest for anybody here on this list nor if
it was already discussed before. But as I did not find any information
via a google search I post this here anyway.

First I wanted gnus to automatically sign all sent messages. This was
rather easy as a simple

(add-hook gnus-message-setup-hook 'mml-secure-message-sign-pgpmime)

did the job.

But then I wanted to go one step further and not only sign but also
encrypt all messages, at least if this is possible (i.e. if the
recipient also uses PGP).

The first attempt was the following:

(add-hook gnus-message-setup-hook 'mml-secure-message-encrypt-pgpmime)

But this _always_ tries to encrypt the message, even if the recipient
has no PGP key. So I wrote the following hook:

(add-hook
 'message-send-hook
 (lambda ()
   (let ((recipient (message-fetch-field "To")))
     (cond ((and (not (null recipient))
		 (or (pgg-lookup-key recipient)
		     (pgg-fetch-key pgg-default-keyserver-address recipient)))
	    (mml-secure-message-encrypt-pgpmime))
	   (t
	    (mml-secure-message-sign-pgpmime))))))

This works perfectly for me. Gnus encrypts the message if gpg already
has the recipient's key in its keyring or if it can get the key from a
keyserver. Otherwise the message is only signed.

Maybe this helps someone.

-- 

                 God is real ...
\|/ ____ \|/     ... unless declared integer.
"@'/ ,. \`@"     
\_| \__/ |_/     Mail me : news@u-h-l.de
   \__U_/        WWW     : www.u-h-l.de
                 PGP     : 0x128F9DEC

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-15 21:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-29 17:31 Automatically sign/encrypt messages Klaus Uhl
2004-01-30 19:06 ` Ted Zlatanov
     [not found]   ` <87ptd0jsqv.fsf@u-h-l.de>
2004-02-02 20:27     ` Ted Zlatanov
2014-05-15 21:41       ` Peter Münster
2004-02-04 16:33 ` Eric Simon
2004-02-04 16:51   ` Klaus Uhl
     [not found]     ` <87znby7oby.fsf@pc70-23.unine.ch>
     [not found]       ` <87r7xar7i9.fsf@ulm.my.lan>
2004-02-05 18:37         ` Eric Simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).