Fix sha1 test issue

This commit is contained in:
Sun Yimin 2023-03-09 13:18:42 +08:00 committed by GitHub
parent 236c37dab8
commit d968b80e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1681,6 +1681,7 @@ func TestSHA1(t *testing.T) {
if sa := cert.SignatureAlgorithm; sa != ECDSAWithSHA1 {
t.Errorf("signature algorithm is %v, want %v", sa, ECDSAWithSHA1)
}
if !debugAllowSHA1 {
if err = cert.CheckSignatureFrom(cert); err == nil {
t.Fatalf("certificate verification succeeded incorrectly")
}
@ -1690,9 +1691,11 @@ func TestSHA1(t *testing.T) {
defer func(old bool) { debugAllowSHA1 = old }(debugAllowSHA1)
debugAllowSHA1 = true
}
if err = cert.CheckSignatureFrom(cert); err != nil {
t.Fatalf("SHA-1 certificate did not verify with GODEBUG=x509sha1=1: %v", err)
}
}
// certMissingRSANULL contains an RSA public key where the AlgorithmIdentifier