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.
相关产品推荐
相关产品推荐

