Bypass Invalid Public key

Peter Pentchev roam at
Mon Oct 6 11:35:48 CEST 2008

On Thu, Oct 02, 2008 at 05:01:39PM -0500, Duwaine Robinson wrote:
> Hi All,
> Is there a way to get GnuPG to complete encryption, if there is at least
> one valid public key specified? I am trying automate my encryption
> process, and I am hoping to be able to get away with not having to
> specify error handling if one or more of my public keys does not exist
> on the key ring.
> Any help is greatly appreciated.
> Thank you

I'm not sure that what you're asking would be such a good idea; after
all, it boils down to "let GnuPG report success even if it did not
really do most of what you asked it to, with no real way of knowing
which parts it did do and which parts it didn't" :)

IMHO, an alternative would be to actually *ask* it which keys it does
have before attempting the encryption; you can do something like:

  gpg --list-keys --with-colons 16194553 87E057BE 5DBFAB91

...and then look for the lines beginning with "pub".  If this is
a Unixish environment, you could try filtering the output through
  awk -F: '$1 == "pub" && $12 ~ /E/ { print $5 }'

..or, of course, just use your programming language's text processing
capabilities to extract the fifth field of the "pub" lines that contain
an "E" character in the twelfth field :)  All of them will identify
valid public keys that GnuPG can actually encrypt to (the uppercase 'E'
signifies exactly that, according to the doc/DETAILS file in the GnuPG

Hope that helps :)


Peter Pentchev	roam at    roam at    roam at
PGP key:
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
because I didn't think of a good beginning of it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: </pipermail/attachments/20081006/7865cc05/attachment.pgp>

More information about the Gnupg-users mailing list