Skip to content

Commit 35f4ec1

Browse files
committed
crypto/x509: ignore harmless edge case in TestSystemRoots
The no-cgo validation hack lets in certificates from the root store that are not marked as roots themselves, but are signed by a root; the cgo path correctly excludes them. When TestSystemRoots compares cgo and no-cgo results it tries to ignore them by ignoring certificates which pass validation, but expired certificates were failing validation. Letting through expired certs is harmless anyway because we will refuse to build chains to them. Fixes #29497 Change-Id: I341e50c0f3426de2763468672f9ba1d13ad6cfba Reviewed-on: https://go-review.googlesource.com/c/156330 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 303a596 commit 35f4ec1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/crypto/x509/root_darwin_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ func TestSystemRoots(t *testing.T) {
6464
if _, ok := sysPool[string(c.Raw)]; ok {
6565
delete(sysPool, string(c.Raw))
6666
} else {
67-
// verify-cert lets in certificates that are not trusted roots, but are
68-
// signed by trusted roots. This should not be a problem, so confirm that's
69-
// the case and skip them.
67+
// verify-cert lets in certificates that are not trusted roots, but
68+
// are signed by trusted roots. This is not great, but unavoidable
69+
// until we parse real policies without cgo, so confirm that's the
70+
// case and skip them.
7071
if _, err := c.Verify(VerifyOptions{
7172
Roots: sysRoots,
7273
Intermediates: allCerts,
7374
KeyUsages: []ExtKeyUsage{ExtKeyUsageAny},
75+
CurrentTime: c.NotBefore, // verify-cert does not check expiration
7476
}); err != nil {
7577
t.Errorf("certificate only present in non-cgo pool: %v (verify error: %v)", c.Subject, err)
7678
} else {

0 commit comments

Comments
 (0)