I'm trying to import a public key provided to me in python but for some reason the code always says "no fingerprint found" for this key. I've been able to use the same code to import another public gpg key. The only difference is that the one i was able to import looks normal when opening in a text file
-----BEGIN PGP MESSAGE-----
hQIMA4KP8a3P3lh+ARAArIKl7NQQ2nwLrbScEXB4YwHK8PaBU/zvcO4flo9XHfhj
...
-----END PGP MESSAGE-----
while the other one looks like a bunch of jumbled characters. snippit of jumbled file
Here is the python code i am using to do my import
import boto3
import os
import gnupg
from pprint import pprint
gpg = gnupg.GPG()
#commented out part where i pull file from s3 to /tmp/Public_key.txt
public_keys = gpg.list_keys()
private_keys = gpg.list_keys(True)
print ('public keys:')
pprint(public_keys)
print ('private keys:')
pprint(private_keys)
# import
key_data = open('/tmp/Public_Key.txt').read()
import_result = gpg.import_keys(key_data)
for k in import_result.results:
print("printing import results public key")
print(k)
Things i have tried are: reading the file as binary instead which also didn't work
with open('/tmp/Public_Key.txt', mode='rb') as file: # b is important -> binary
key_data = file.read()
Another thing to note, the key is able to be imported easily when i use CLI from my terminal using
gpg --import Public_Key.txt
So is it because i need to convert it to a string first that is messing it up?
The output of the import attempt in python is
{'fingerprint': None, 'status': 'No valid data found'}