Subject: | Small patch to make Mail::GPG support passphraseless keys |
Mail::GPG will refuse to work with a key with no passphrase. Of course,
this is usually a bad idea, but if you choose to do so, it should be
possible.
I was generating a series of messages using a variety of test keys, zero
interest in putting passphrases on them. Mail::GPG dies with "No
passphrase set" if the passphrase is set to '' (an empty string).
By simply changing those checks to see if $passphrase is defined, I get
the desired behavior when a passphrase is defined as '': using a
passphraseless key works, but the error-checking still functions if the
user forgets to specify a passphrase at all. Simple patch attached.
Subject: | Mail_GPG_blankpassphrase.diff |
--- Mail-GPG-1.0.6/lib/Mail/GPG.pm.orig 2006-11-18 03:49:05.000000000 -0500
+++ Mail-GPG-1.0.6/lib/Mail/GPG.pm 2011-07-27 18:00:39.000000000 -0400
@@ -446,7 +446,7 @@
#-- check parameters
die "No key_id set" if $key_id eq '';
- die "No passphrase set" if $passphrase eq '';
+ die "No passphrase set" if not defined $passphrase;
#-- build entity for signed version
#-- (only the 2nd part with the signature data
@@ -564,7 +564,7 @@
#-- check parameters
die "No key_id set" if not $_no_sign and $key_id eq '';
- die "No passphrase set" if not $_no_sign and $passphrase eq '';
+ die "No passphrase set" if not $_no_sign and not defined $passphrase;
#-- build entity for encrypted version
#-- (only the 2nd part with the encrypted data
@@ -687,7 +687,7 @@
#-- check parameters
die "No key_id set" if $key_id eq '';
- die "No passphrase set" if $passphrase eq '';
+ die "No passphrase set" if not defined $passphrase;
die "Entity has no body" if not $entity->bodyhandle;
#-- check, if body content-transfer-encoding is 7bit safe
@@ -804,7 +804,7 @@
#-- check parameters
die "No key_id set" if $key_id eq '';
- die "No passphrase set" if $passphrase eq '';
+ die "No passphrase set" if not defined $passphrase;
}
#-- check parameters