Fix public key verification with empty certificate chain

This commit is contained in:
世界
2026-11-24 22:45:19 +08:00
parent d553a29433
commit f41c2e62ca
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -276,6 +276,9 @@ func verifyConnection(rootCAs *x509.CertPool, timeFunc func() time.Time, serverN
}
func VerifyPublicKeySHA256(knownHashValues [][]byte, rawCerts [][]byte) error {
if len(rawCerts) == 0 {
return E.New("missing remote certificate")
}
leafCertificate, err := x509.ParseCertificate(rawCerts[0])
if err != nil {
return E.Cause(err, "failed to parse leaf certificate")