Source file src/crypto/x509/root_plan9.go

     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  
     7  package x509
     8  
     9  import (
    10  	"os"
    11  )
    12  
    13  // Possible certificate files; stop after finding one.
    14  var certFiles = []string{
    15  	"/sys/lib/tls/ca.pem",
    16  }
    17  
    18  func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) {
    19  	return nil, nil
    20  }
    21  
    22  func loadSystemRoots() (*CertPool, error) {
    23  	roots := NewCertPool()
    24  	var bestErr error
    25  	for _, file := range certFiles {
    26  		data, err := os.ReadFile(file)
    27  		if err == nil {
    28  			roots.AppendCertsFromPEM(data)
    29  			return roots, nil
    30  		}
    31  		if bestErr == nil || (os.IsNotExist(bestErr) && !os.IsNotExist(err)) {
    32  			bestErr = err
    33  		}
    34  	}
    35  	if bestErr == nil {
    36  		return roots, nil
    37  	}
    38  	return nil, bestErr
    39  }
    40  

View as plain text