mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
crypto/tls: fetch root certificates using Mac OS API
Fixes #1009. R=adg, rsc CC=golang-dev https://golang.org/cl/5262041
This commit is contained in:
parent
604bd70085
commit
38fb09b412
9 changed files with 208 additions and 31 deletions
27
src/pkg/crypto/tls/root_unix.go
Normal file
27
src/pkg/crypto/tls/root_unix.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// 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.
|
||||
|
||||
package tls
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// Possible certificate files; stop after finding one.
|
||||
var certFiles = []string{
|
||||
"/etc/ssl/certs/ca-certificates.crt", // Linux etc
|
||||
}
|
||||
|
||||
func initDefaultRoots() {
|
||||
roots := x509.NewCertPool()
|
||||
for _, file := range certFiles {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
if err == nil {
|
||||
roots.AppendCertsFromPEM(data)
|
||||
break
|
||||
}
|
||||
}
|
||||
varDefaultRoots = roots
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue