当前位置: > > > > 无效参数:未找到装甲数据
无效参数:未找到装甲数据
来源:stackoverflow
2024-04-29 08:54:33
0浏览
收藏
Golang小白一枚,正在不断学习积累知识,现将学习到的知识记录一下,也是将我的所得分享给大家!而今天这篇文章《无效参数:未找到装甲数据》带大家来了解一下##content_title##,希望对大家的知识积累有所帮助,从而弥补自己的不足,助力实战开发!
问题内容
当我尝试加载装甲 gpg 公钥来验证签名时,收到错误 openpgp:无效参数:未找到装甲数据
我的代码(一些数据被缩短以更好地适应):
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
}
完整的公钥,完整的签名。
解决方案
编辑:我认为这与您的公钥装甲无效有关。下面是一个工作函数的链接,其中包含示例 const e2ePublicKey 。
他们不使用 strings.NewReader(pubKey),而是使用:
keyring,错误:= openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pubKey))
也许还有另一个 bytes.NewBufferString 作为签名。
(来自 )
今天带大家了解了的相关知识,希望对你有所帮助;关于Golang的技术知识我们会一点点深入介绍,欢迎大家关注米云公众号,一起学习编程~
