【问题标题】:Python GNUPG - Trust Imported Key?Python GNUPG - 信任导入的密钥?
【发布时间】:2021-08-14 14:15:39
【问题描述】:

与此类似: gnupg: There is no assurance this key belongs to the named user

但我想在 Python 中设置导入密钥对的信任级别。这可能吗?如果有,怎么做?

在尝试使用公钥加密文件后,我收到了以下消息:

"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"

这是在运行以下命令之后:

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 返回:

'invalid recipient'

编辑:

private_key_recipient = 'TestUser@Company.Com'

【问题讨论】:

  • 我们能看看你是怎么得到private_key_recipient的吗?
  • @DashWinterson - 这实际上是从 GCP 机密 JSON 中获得的。这是一个字符串:'TestUser@Company.Com'。
  • private_key_recipient 应该是公共 GPG 密钥 iirc
  • @DashWinterson - 我经过:gist.github.com/ryantuck/56c5aaa8f9124422ac964629f4c8deb0 和:saltycrane.com/blog/2011/10/python-gnupg-gpg-example 在这两个文档中,他们都使用了收件人列表,其中只有一个。我尝试将我的单个字符串更改为单个收件人的列表,结果仍然相同。
  • 只看模块似乎有一个trust_keys 方法。这样做是你想要的吗?

标签: python gnupg trust


【解决方案1】:

看着pydoc gnupg我明白了:

trust_keys(self, fingerprints, trustlevel) 

它没有记录,但听起来像你想要的。

【讨论】:

    猜你喜欢
    • 2014-04-27
    • 2014-05-27
    • 2015-08-22
    • 2015-09-07
    • 2018-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    相关资源
    最近更新 更多