From 0bf67506b05419bd902511c0d0c5181c0f053692 Mon Sep 17 00:00:00 2001 From: pinmarch Date: Sun, 9 Jul 2017 00:52:42 +0900 Subject: [PATCH] solves error (Symkey decrypt failed: Invalid secret key ID) "Symkey decrypt failed: Invalid secret key ID" problem in https://stackoverflow.com/questions/12540226/cryptopenpgp-symkey-decrypt-failed-invalid-secret-key-id . I use openpgp.js for the encryption of messages and get the same error. It seems openpgp.js uses the subkey for encryption of the sessionkey. So I suggest "$kb->key_by_id($sym_key->key_id)" instead of "$kb->encrypting_key". --- lib/Crypt/OpenPGP.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Crypt/OpenPGP.pm b/lib/Crypt/OpenPGP.pm index 2f074d1..41b4f4a 100644 --- a/lib/Crypt/OpenPGP.pm +++ b/lib/Crypt/OpenPGP.pm @@ -609,7 +609,7 @@ sub decrypt { return $pgp->error("Can't find a secret key to decrypt message") unless $kb || $cert; if ($kb) { - $cert = $kb->encrypting_key; + $cert = $kb->key_by_id($sym_key->key_id); $cert->uid($kb->primary_uid); } if ($cert->is_protected) {