mirror of
https://github.com/autc04/Retro68.git
synced 2024-09-08 20:55:01 +00:00
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// 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.
|
|
|
|
// +build dragonfly freebsd linux nacl netbsd openbsd solaris
|
|
|
|
package x509
|
|
|
|
import "io/ioutil"
|
|
|
|
// Possible directories with certificate files; stop after successfully
|
|
// reading at least one file from a directory.
|
|
var certDirectories = []string{
|
|
"/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139
|
|
"/system/etc/security/cacerts", // Android
|
|
}
|
|
|
|
func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func initSystemRoots() {
|
|
roots := NewCertPool()
|
|
for _, file := range certFiles {
|
|
data, err := ioutil.ReadFile(file)
|
|
if err == nil {
|
|
roots.AppendCertsFromPEM(data)
|
|
systemRoots = roots
|
|
return
|
|
}
|
|
}
|
|
|
|
for _, directory := range certDirectories {
|
|
fis, err := ioutil.ReadDir(directory)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
rootsAdded := false
|
|
for _, fi := range fis {
|
|
data, err := ioutil.ReadFile(directory + "/" + fi.Name())
|
|
if err == nil && roots.AppendCertsFromPEM(data) {
|
|
rootsAdded = true
|
|
}
|
|
}
|
|
if rootsAdded {
|
|
systemRoots = roots
|
|
return
|
|
}
|
|
}
|
|
|
|
// All of the files failed to load. systemRoots will be nil which will
|
|
// trigger a specific error at verification time.
|
|
}
|