Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (35 sloc) 1.09 KB
/*
Package cacerts contains CA certificates from the golang:1.5.1 docker image at /etc/ssl/certs/ca-certificates.crt.
Useful for when docker images are created from the scratch image.
See https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07 for details.
*/
package cacerts // import "go.pedge.io/cacerts"
import (
"crypto/tls"
"crypto/x509"
"net/http"
)
// NewX509CertPool returns a new *x509.CertPool with certificates attached.
func NewX509CertPool() *x509.CertPool {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(pemCerts)
return pool
}
// NewTLSConfig returns a new *tls.Config with certificates attached.
func NewTLSConfig() *tls.Config {
return &tls.Config{
RootCAs: NewX509CertPool(),
}
}
// NewHTTPTransport returns a new *http.Transport with certificates attached.
func NewHTTPTransport() *http.Transport {
return &http.Transport{
TLSClientConfig: NewTLSConfig(),
}
}
// NewHTTPClient returns a new *http.Client with certificates attached.
func NewHTTPClient() *http.Client {
return &http.Client{
Transport: NewHTTPTransport(),
}
}