1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-01-16 07:51:33 +01:00
drone-cli/vendor/github.com/jackspirou/syscerts/root_darwin.go
jackspirou 67e0ed9b4f use the drone.NewClientTokenTLS method and vendor by hand
updating github.com/drone/drone-go vendored dep

vendor by hand

update vendored drone-go

fixing syscerts

fixing windows 509x package errors

use TLS CA roots with windows later
2016-03-14 23:54:50 -05:00

40 lines
1.0 KiB
Go

// Copyright 2013 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.
//go:generate go run root_darwin_arm_gen.go -output root_darwin_armx.go
package syscerts
import (
"crypto/x509"
"os"
"os/exec"
)
func execSecurityRoots() (*x509.CertPool, error) {
roots := x509.NewCertPool()
cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain")
data, err := cmd.Output()
if err != nil {
return nil, err
}
roots.AppendCertsFromPEM(data)
// if available add the Mac OSX System Keychain
if _, err := os.Stat("/Library/Keychains/System.keychain"); err == nil {
cmd = exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/Library/Keychains/System.keychain")
data, err = cmd.Output()
if err != nil {
return nil, err
}
roots.AppendCertsFromPEM(data)
}
return roots, nil
}
func initSystemRoots() {
systemRoots, _ = execSecurityRoots()
}