【问题标题】:invalid argument: no armored data found无效参数:未找到装甲数据
【发布时间】:2021-01-14 08:24:53
【问题描述】:

当我尝试加载装甲 GPG 公钥来验证签名时,我收到错误 openpgp: invalid argument: no armored data found

我的代码(一些数据被缩短以更好地适应):

pubKey := `-----BEGIN PGP PUBLIC KEY BLOCK-----
xsFNBF/9Xn [...] =Yo8+
-----END PGP PUBLIC KEY BLOCK-----`

content := "Hello World"

signature := `-----BEGIN PGP SIGNATURE-----
wsFcBAE [...] =z3nL
-----END PGP SIGNATURE-----`

keyring, err := openpgp.ReadArmoredKeyRing(strings.NewReader(pubKey))
if err != nil {
    // Errors out here with: openpgp: invalid argument: no armored data found
    // ...
}

// Code never gets this far but I'm including this in case I'm using it all wrong...
_, err = openpgp.CheckArmoredDetachedSignature(keyring, strings.NewReader(content), strings.NewReader(signature))
if err != nil {
    return false, err
}

Entire public key, entire signature.

【问题讨论】:

    标签: go cryptography openpgp


    【解决方案1】:

    编辑:我认为这与您的公钥盔甲无效有关。下面是一个工作函数的链接,带有一个示例const e2ePublicKeypublic key

    他们不使用strings.NewReader(pubKey),而是使用:

    keyring, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pubKey))

    也许是另一个bytes.NewBufferString 签名。

    (来自src

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多