root_darwin.go 684 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2013 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. //go:generate go run root_darwin_arm_gen.go -output root_darwin_armx.go
  5. package system
  6. import (
  7. "crypto/x509"
  8. "errors"
  9. "os/exec"
  10. )
  11. func execSecurityRoots() ([]*x509.Certificate, error) {
  12. cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain")
  13. data, err := cmd.Output()
  14. if err != nil {
  15. return nil, err
  16. }
  17. roots, ok := appendPEM(nil, data)
  18. if !ok {
  19. return nil, errors.New("transport: no system roots found")
  20. }
  21. return roots, nil
  22. }