go - 在 Golang 中如何判断两个证书对是由不同的 CA 颁发的?

标签 go

我有一个使用自签名 tls 证书的 Golang http 服务器。我有一对这样的证书和 key 。现在,假设我有一个类似的证书和 key 对。我想检测这两对是否由两个不同的 CA 签发?在这种情况下,我无权访问 CA 证书。我可以假设链长 = 1。

我试图检查 Certificate.Issuer 结构。但我看不出有什么不同。我该怎么做?

谢谢。

最佳答案

SubjectKeyId fields两个不同的证书会有所不同。

此字段是公钥的哈希值:

The keyIdentifier is composed of the 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey (excluding the tag, length, and number of unused bits).

https://www.rfc-editor.org/rfc/rfc3280#section-4.2.1.2

对于非自签名证书,将遵循 AuthorityKeyId 字段一直到根证书,然后检查普通成员的证书链,再次使用主题 key 。

关于go - 在 Golang 中如何判断两个证书对是由不同的 CA 颁发的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53930168/

相关文章:

json - 将[][]接口(interface)转换为[][]字符串

去插件 - "plugin was built with a different version of package"

string - 字符串的不变性和并发性

go - 在我的 golang 程序中解析来自 shell 程序的字节

CLI 与程序的纯 C/C++ 库?

go - 为什么这个 Go 程序只能处理发送到 channel 的奇数整数?

go - 如何停止 rethinkdbs Next (.Changes())

go - 如何在 GKE 中使用 HTTPS 部署 Echo 应用程序?

go - 如何从 go *gin.context 对象中获取所有查询参数

go - byte slice 自行更改