root_plan9.go 844 B

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