1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-01-15 15:31:33 +01:00
drone-cli/vendor/github.com/jackspirou/syscerts
2016-03-18 15:17:24 -07:00
..
LICENSE use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
README.md use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_bsd.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_cgo_darwin.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_darwin_arm_gen.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_darwin_armx.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_darwin.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_linux.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_nacl.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_plan9.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_solaris.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_unix.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root_windows.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00
root.go use the drone.NewClientTokenTLS method and vendor by hand 2016-03-14 23:54:50 -05:00

syscerts

Gather local system certificates in Go via a public SystemRootsPool method.

What does this do?

Provide a way to gather local system certificates on different OS platforms.

How does it do it?

It uses the crypto/x509 package and provides a single public method called SystemRootsPool() to return a *x509.CertPool object.

How do you use it?

// gather CA certs
certpool := syscerts.SystemRootsPool()

// place them in an HTTP client for trusted SSL/TLS connections
tlsConfig := &tls.Config{RootCAs: certpool}
transport := &http.Transport{TLSClientConfig: tlsConfig}
client := &http.Client{Transport: transport}

// make a request
resp, err := client.Do(req)

Why even do it?

The crypto/x509 package already has a systemRootsPool method. The crypto/x509.systemRootsPool method is almost the same as github.com/jackspirou/syscerts.SystemRootsPool. The difference? The crypto/x509.systemRootsPool method is private so you cannot access it. :(

There are plans for the crypto/x509.systemRootsPool method to become public in Go 1.7. When this happens you might no longer need github.com/jackspirou/syscerts.SystemRootsPool.

The only reason you may still use this package after the Go 1.7 release might be for the Mac OSX System Keychain certs which are not included in the crypto/x509 package. Relevant lines below:

Find more about this Go issue here: https://github.com/golang/go/issues/13335