aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto/x509/root_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/x509/root_plan9.go')
-rw-r--r--libgo/go/crypto/x509/root_plan9.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/libgo/go/crypto/x509/root_plan9.go b/libgo/go/crypto/x509/root_plan9.go
index 9965caa..ebeb7df 100644
--- a/libgo/go/crypto/x509/root_plan9.go
+++ b/libgo/go/crypto/x509/root_plan9.go
@@ -6,7 +6,10 @@
package x509
-import "io/ioutil"
+import (
+ "io/ioutil"
+ "os"
+)
// Possible certificate files; stop after finding one.
var certFiles = []string{
@@ -17,17 +20,18 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
return nil, nil
}
-func initSystemRoots() {
+func loadSystemRoots() (*CertPool, error) {
roots := NewCertPool()
+ var bestErr error
for _, file := range certFiles {
data, err := ioutil.ReadFile(file)
if err == nil {
roots.AppendCertsFromPEM(data)
- systemRoots = roots
- return
+ return roots, nil
+ }
+ if bestErr == nil || (os.IsNotExist(bestErr) && !os.IsNotExist(err)) {
+ bestErr = err
}
}
-
- // All of the files failed to load. systemRoots will be nil which will
- // trigger a specific error at verification time.
+ return nil, bestErr
}