在x509库中,有一个名为CheckSignature的函数。我有点不知道该把什么传递给signed。它应该是什么?
功能是
func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) (err error)https://golang.org/src/crypto/x509/x509.go?s=21660:21759#L623
另一件我想加倍的事情是,如果我用与证书相关的私钥签名某个东西,该签名会传递这个CheckSignature函数吗?
发布于 2015-10-09 01:42:39
signed看起来是签名者ASN.1 DER格式的证书。
发布于 2021-11-11 17:48:34
您需要使用父证书来检查已颁发证书上的签名。例:
// parent is the parent x509.Certificate
// cert is the certificate signed by the parent
// alg is the algorithm used to sign, eg x509.PureEd25519
alg := cert.SignatureAlgorithm
err := parent.CheckSignature(alg, cert.RawTBSCertificate, cert.Signature)
if err != nil {
return errors.New("Signature invalid")
}https://stackoverflow.com/questions/33026915
复制相似问题