Commit 2d4ccbfe authored by Ian Lance Taylor's avatar Ian Lance Taylor

crypto/x509: don't return nil, nil from SystemCertPool

If there are no certs, return an empty pool, not nil.

Fixes #21405

Change-Id: Ib4ac9d5c4a8cef83dd53565b0707a63b73ba0a8b
Reviewed-on: https://go-review.googlesource.com/103596
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarFilippo Valsorda <filippo@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent c96ac60b
......@@ -33,5 +33,8 @@ func loadSystemRoots() (*CertPool, error) {
bestErr = err
}
}
if bestErr == nil {
return roots, nil
}
return nil, bestErr
}
......@@ -80,7 +80,7 @@ func loadSystemRoots() (*CertPool, error) {
}
}
if len(roots.certs) > 0 {
if len(roots.certs) > 0 || firstErr == nil {
return roots, nil
}
......
......@@ -103,10 +103,6 @@ func TestEnvVars(t *testing.T) {
}
if r == nil {
if tc.cns == nil {
// Expected nil
return
}
t.Fatal("nil roots")
}
......
......@@ -1656,9 +1656,6 @@ func TestSystemCertPool(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("not implemented on Windows; Issue 16736, 18609")
}
if runtime.GOOS == "nacl" {
t.Skip("not implemented on NaCl; Issue 24561")
}
a, err := SystemCertPool()
if err != nil {
t.Fatal(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment