root_unix.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2011 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. // +build dragonfly freebsd linux openbsd netbsd solaris
  5. package x509
  6. import "io/ioutil"
  7. // Possible certificate files; stop after finding one.
  8. var certFiles = []string{
  9. "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
  10. "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
  11. "/etc/ssl/ca-bundle.pem", // OpenSUSE
  12. "/etc/ssl/cert.pem", // OpenBSD
  13. "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD/DragonFly
  14. }
  15. func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) {
  16. return nil, nil
  17. }
  18. func initSystemRoots() {
  19. roots := NewCertPool()
  20. for _, file := range certFiles {
  21. data, err := ioutil.ReadFile(file)
  22. if err == nil {
  23. roots.AppendCertsFromPEM(data)
  24. systemRoots = roots
  25. return
  26. }
  27. }
  28. // All of the files failed to load. systemRoots will be nil which will
  29. // trigger a specific error at verification time.
  30. }