Question

I need to create a public key for a unix machine to send me encrypted data.

What I do is use the following constructor for creating the PGPSecreyKey.

PGPSecretKey secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(),
            "Test test@mail.com", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC");

When opened with Kleopatra (to check my certificate) I see Name: "Test test@mail.com" and Email: "".

How can I create a PGP key with both a name and email (and comment if possible).

Thanks in advance!

Was it helpful?

Solution

to add an emailaddress you have to concat the email to the userID. LIke

PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(),
            "Hans Mueller <hans.mueller@mail.com>", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC");

OTHER TIPS

to Fix this issue you have to add \n newline between name and Email

PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(),
            "Hans Mueller \n <hans.mueller@mail.com>", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top