github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/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  //go:build plan9
     6  // +build plan9
     7  
     8  package x509
     9  
    10  import (
    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 := os.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  }