ProtonMail/go-crypto

Error: gopenpgp: error in encrypting asymmetrically: openpgp: invalid argument: cannot encrypt a message to key id ... because the key has no valid encryption keys

Closed this issue · 1 comments

Discussed in #256

Originally posted by dwlpra December 4, 2024
I encountered an issue when trying to encrypt a message using gopenpgp. The following error message is displayed:

gopenpgp: error in encrypting asymmetrically: openpgp: invalid argument: cannot encrypt a message to key id 46e5290990b7262a because it has no valid encryption keys.

When I checked the key details using the gpg --list-keys command, here is the output:

pub   rsa2048 2014-02-05 [SCEAR]
      3DF044965B590BBB3A702BF946E5290990B7262A
uid           [ unknown] *** pgp key encryption ***
sub   rsa2048 2014-02-05 [SCEAR]

Steps to Reproduce:
I loaded my public key using gopenpgp.
When trying to encrypt a message with the public key, the error above was triggered.
Observations:
Based on the gpg --list-keys output, the key capabilities are SCEAR:

S: Sign
C: Certify
E: Encrypt
A: Authenticate
R: Subkey
However, gopenpgp considers this key invalid for encryption.

Questions:
Is there an issue with my PGP key configuration?
Does gopenpgp require specific key attributes to allow encryption?
How can I verify that my key is valid for encryption when using gopenpgp?

twiss commented

You don't have to create both a discussion and an issue, one is enough.