You need to enable JavaScript to run this app. OpenPGP加载armored GPG公钥验证签名时提示no armored data found错误
优惠活动
大模型
产品
解决方案
定价
更多

OpenPGP加载armored GPG公钥验证签名时提示no armored data found错误

问题现象

尝试加载Armored格式封装的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 {
    // 代码执行到此处抛出错误:openpgp: invalid argument: no armored data found
    // ...
}

// 受上游错误阻断,实际无法运行到后续逻辑,附上相关代码以排查是否存在API使用不当问题
_, err = openpgp.CheckArmoredDetachedSignature(keyring, strings.NewReader(content), strings.NewReader(signature))
if err != nil {
    return false, err
}

配套准备了完整的公钥、签名测试资源,可用于复现问题、定位异常原因。


内容的提问来源于stack exchange,提问作者Jakub S.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.08 16:36:08