Similar to this: gnupg: There is no assurance this key belongs to the named user
But I want to set the trust level of an imported key pair within Python. Is this possible? And if so, how?
At the moment after trying to encrypt a file with the public key, I'm receiving the message:
"There is no assurance this key belongs to the named user\r\n[GNUPG:] INV_RECP 10 TestUser@Company.Com\r\n[GNUPG:] FAILURE sign-encrypt 53\r\ngpg: [stdin]: sign+encrypt failed: Unusable public key\r\n"
This is after running the following:
with open('Test.txt', 'rb') as f:
status = gpg.encrypt_file(
f,sign=public_key_fingerprint,
recipients=private_key_recipient,
output = output_file
)
status.status returns:
'invalid recipient'
EDIT:
private_key_recipient = 'TestUser@Company.Com'
Looking at pydoc gnupg
I see:
trust_keys(self, fingerprints, trustlevel)
It's not documented, but it sounds like what you want.