open-vault/vendor/github.com/hashicorp/go-rootcerts
Michel Vocks 13ebf5460c
Add TLS options per Nomad backend (#8083)
2020-01-15 11:03:38 +01:00
..
.travis.yml Switch to go modules (#6585) 2019-04-13 03:44:06 -04:00
LICENSE Switch our tri-copy ca loading code to go-rootcerts 2016-05-03 12:23:25 -04:00
Makefile Switch our tri-copy ca loading code to go-rootcerts 2016-05-03 12:23:25 -04:00
README.md Add TLS options per Nomad backend (#8083) 2020-01-15 11:03:38 +01:00
doc.go Switch our tri-copy ca loading code to go-rootcerts 2016-05-03 12:23:25 -04:00
go.mod Vendor and prep for beta 2019-06-20 23:43:02 -04:00
go.sum Vendor and prep for beta 2019-06-20 23:43:02 -04:00
rootcerts.go Add TLS options per Nomad backend (#8083) 2020-01-15 11:03:38 +01:00
rootcerts_base.go Switch our tri-copy ca loading code to go-rootcerts 2016-05-03 12:23:25 -04:00
rootcerts_darwin.go Switch our tri-copy ca loading code to go-rootcerts 2016-05-03 12:23:25 -04:00

README.md

rootcerts

Functions for loading root certificates for TLS connections.


Go's standard library crypto/tls provides a common mechanism for configuring TLS connections in tls.Config. The RootCAs field on this struct is a pool of certificates for the client to use as a trust store when verifying server certificates.

This library contains utility functions for loading certificates destined for that field, as well as one other important thing:

When the RootCAs field is nil, the standard library attempts to load the host's root CA set. This behavior is OS-specific, and the Darwin implementation contains a bug that prevents trusted certificates from the System and Login keychains from being loaded. This library contains Darwin-specific behavior that works around that bug.

Example Usage

Here's a snippet demonstrating how this library is meant to be used:

func httpClient() (*http.Client, error)
	tlsConfig := &tls.Config{}
	err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{
		CAFile:      os.Getenv("MYAPP_CAFILE"),
		CAPath:      os.Getenv("MYAPP_CAPATH"),
		Certificate: os.Getenv("MYAPP_CERTIFICATE"),
	})
	if err != nil {
		return nil, err
	}
	c := cleanhttp.DefaultClient()
	t := cleanhttp.DefaultTransport()
	t.TLSClientConfig = tlsConfig
	c.Transport = t
	return c, nil
}