GNUPG指纹未识别为加密的有效收件人
密钥的GNUPG指纹未被确定为加密的有效收件人。根据此doc https://pythonhosted.org/python-python-gython-gnupg/ #encryptig 我们可以使用指纹。但是它不起作用。
>>> import gnupg
>>> gpg = gnupg.GPG(gnupghome="/home/user/.gnupg")
>>> key_data = open('/home/user/path/to/public_key.pgp').read()
>>> import_result = gpg.import_keys(key_data)
>>> test_status = gpg.encrypt('test', import_result.fingerprints[0])
>>> test_status.status
'invalid recipient'
>>>
gnupg fingerprint of key is not identified as valid recipient for encryption. According to this doc https://pythonhosted.org/python-gnupg/#encryption we can use fingerprint. But its not working.
>>> import gnupg
>>> gpg = gnupg.GPG(gnupghome="/home/user/.gnupg")
>>> key_data = open('/home/user/path/to/public_key.pgp').read()
>>> import_result = gpg.import_keys(key_data)
>>> test_status = gpg.encrypt('test', import_result.fingerprints[0])
>>> test_status.status
'invalid recipient'
>>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要从命令行尝试相同的过程,则在尝试将消息加密到收件人(
gpg -ea -ea -r&lt< enterprint>
)时,会看到以下错误。在将其用作收件人之前“信任”密钥。您可以使用
trust_keys
方法来执行此操作:另外,您可以设置
ewnder_trust
参数:ewndery_trust
option 在文档中。If you were to attempt the same process from the command line, you would see the following error when attempting to encrypt a message to the recipient (
gpg -ea -r <fingerprint>
):It is necessary to "trust" the key before you can use it as a recipient. You can do this using the
trust_keys
method:Alternately, you can set the
always_trust
parameter:The
always_trust
option is described in the documentation.