github.com/fisco-bcos/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/x509/root_plan9.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build plan9 6 7 package x509 8 9 import ( 10 "io/ioutil" 11 "os" 12 ) 13 14 // Possible certificate files; stop after finding one. 15 var certFiles = []string{ 16 "/sys/lib/tls/ca.pem", 17 } 18 19 func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 20 return nil, nil 21 } 22 23 func loadSystemRoots() (*CertPool, error) { 24 roots := NewCertPool() 25 var bestErr error 26 for _, file := range certFiles { 27 data, err := ioutil.ReadFile(file) 28 if err == nil { 29 roots.AppendCertsFromPEM(data) 30 return roots, nil 31 } 32 if bestErr == nil || (os.IsNotExist(bestErr) && !os.IsNotExist(err)) { 33 bestErr = err 34 } 35 } 36 if bestErr == nil { 37 return roots, nil 38 } 39 return nil, bestErr 40 }