GNOME Bugzilla – Bug 677088
Unable to decrypt gpg encrypted and signed part if signing keys is missing
Last modified: 2012-06-13 13:58:02 UTC
When decrypting a part that is gpg signed and encrypted and the key used to sign the part is not in the local keyring, then "gpg --decrypt" has an exit code of 2. gpg_decrypt in gmime_gpg_context.c interprets this as a failure and returns NULL. As you can see in the example gpg output below, the status fd contains the correct information (DECRYPTION_OK and ERRSIG). Instead of returning NULL gpg_decrypt should return a GMimeDecryptResult with a signature list with a GMimeSignature with a status of GMIME_SIGNATURE_STATUS_ERROR or something similar. Example gpg output: $ LANG=C gpg --verbose --no-secmem-warning --no-greeting --no-tty --charset=UTF-8 --status-fd=2 --decrypt --output /dev/null gpg: armor header: Version: GnuPG v1.4.10 (GNU/Linux) gpg: public key is 936691BB [GNUPG:] ENC_TO ED34A39B936691BB 1 0 gpg: no secret subkey for public subkey 12E71AE1 - ignoring gpg: no secret subkey for public subkey 11EBA649 - ignoring gpg: using subkey 936691BB instead of primary key 8C7740AF [GNUPG:] USERID_HINT ED34A39B936691BB Gaudenz Steinlin <gaudenz.steinlin@soziologie.ch> [GNUPG:] NEED_PASSPHRASE ED34A39B936691BB DC5A28E48C7740AF 1 0 gpg: using subkey 936691BB instead of primary key 8C7740AF [GNUPG:] GOOD_PASSPHRASE gpg: encrypted with 2048-bit RSA key, ID 936691BB, created 2006-04-20 "Gaudenz Steinlin <gaudenz.steinlin@soziologie.ch>" [GNUPG:] BEGIN_DECRYPTION gpg: AES256 encrypted data [GNUPG:] DECRYPTION_INFO 2 9 gpg: original file name='' [GNUPG:] PLAINTEXT 62 1338368705 gpg: Signature made Wed May 30 11:05:05 2012 CEST using RSA key ID E43EED4F [GNUPG:] ERRSIG 01301861E43EED4F 1 2 00 1338368705 9 [GNUPG:] NO_PUBKEY 01301861E43EED4F gpg: Can't check signature: public key not found [GNUPG:] DECRYPTION_OKAY [GNUPG:] GOODMDC [GNUPG:] END_DECRYPTION $ echo $? 2 Thanks, Gaudenz
great catch! fixed in git master (will release a new version shortly)