GPG Encryption/Decryption Failing

Sirisha Gopigiri sirisha.gopigiri at
Fri Nov 13 12:52:44 CET 2020


We are trying to use SOPS+GPG to encrypt/decrypt yaml files and we have written some go wrapper using sops library to perform the required encryption/decryption. However when trying to execute this code the gpg library seems to be failing at keygeneration most of the time with the following error.

failed to encrypt new data key with master key "681E3A89EB1DAFD36EB883120A73BB48E26694D8": could not encrypt data key with PGP key: error: key with fingerprint 681E3A89EB1DAFD36EB883120A73BB48E26694D8 is not available in keyring and could not be retrieved from keyserver; GPG binary error: gpg binary failed with error: exit status 2, gpg: 681E3A89EB1DAFD36EB883120A73BB48E26694D8: skipped: No public key

​Seems like it is unable to fetch the public key, we are executing the code locally, so we are using the local public and private keys only.

Though we can list the public key locally, we keep getting the above error quite frequently. However, the encryption/decryption is happening successfully the other times.

Kindly let us know if we are missing anything.

We are facing this error only with gpg 2.1.x version, gpg 1.4.x version seems to be working fine.

Thank you in advance!

Best Regards
Sirisha Gopigiri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Gnupg-users mailing list