2011-10-13 18:59:13 +01:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2011-12-14 15:25:48 +00:00
|
|
|
// +build freebsd linux openbsd netbsd
|
|
|
|
|
2011-10-13 18:59:13 +01:00
|
|
|
package tls
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/x509"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Possible certificate files; stop after finding one.
|
|
|
|
var certFiles = []string{
|
2012-01-18 18:03:00 +00:00
|
|
|
"/etc/ssl/certs/ca-certificates.crt", // Linux etc
|
|
|
|
"/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
|
|
|
|
"/etc/ssl/ca-bundle.pem", // OpenSUSE
|
|
|
|
"/etc/ssl/cert.pem", // OpenBSD
|
|
|
|
"/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
|
2011-10-13 18:59:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func initDefaultRoots() {
|
|
|
|
roots := x509.NewCertPool()
|
|
|
|
for _, file := range certFiles {
|
|
|
|
data, err := ioutil.ReadFile(file)
|
|
|
|
if err == nil {
|
|
|
|
roots.AppendCertsFromPEM(data)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
varDefaultRoots = roots
|
|
|
|
}
|