From c44062814c8063ffb933e28da4072e7a5984fa4a Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 3 May 2016 12:12:30 -0500 Subject: [PATCH] Update atlas-go to latest version that uses go-rootcerts --- Godeps/Godeps.json | 8 +++---- .../hashicorp/atlas-go/v1/client.go | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 8746604fae..dc73fc9067 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -673,13 +673,13 @@ }, { "ImportPath": "github.com/hashicorp/atlas-go/archive", - "Comment": "20141209094003-90-g0008886", - "Rev": "0008886ebfa3b424bed03e2a5cbe4a2568ea0ff6" + "Comment": "20141209094003-92-g95fa852", + "Rev": "95fa852edca41c06c4ce526af4bb7dec4eaad434" }, { "ImportPath": "github.com/hashicorp/atlas-go/v1", - "Comment": "20141209094003-90-g0008886", - "Rev": "0008886ebfa3b424bed03e2a5cbe4a2568ea0ff6" + "Comment": "20141209094003-92-g95fa852", + "Rev": "95fa852edca41c06c4ce526af4bb7dec4eaad434" }, { "ImportPath": "github.com/hashicorp/consul/api", diff --git a/vendor/github.com/hashicorp/atlas-go/v1/client.go b/vendor/github.com/hashicorp/atlas-go/v1/client.go index abae4fe56a..2e61e064b2 100644 --- a/vendor/github.com/hashicorp/atlas-go/v1/client.go +++ b/vendor/github.com/hashicorp/atlas-go/v1/client.go @@ -2,6 +2,7 @@ package atlas import ( "bytes" + "crypto/tls" "encoding/json" "fmt" "io" @@ -14,6 +15,7 @@ import ( "strings" "github.com/hashicorp/go-cleanhttp" + "github.com/hashicorp/go-rootcerts" ) const ( @@ -24,6 +26,14 @@ const ( // default Atlas address. atlasEndpointEnvVar = "ATLAS_ADDRESS" + // atlasCAFileEnvVar is the environment variable that causes the client to + // load trusted certs from a file + atlasCAFileEnvVar = "ATLAS_CAFILE" + + // atlasCAPathEnvVar is the environment variable that causes the client to + // load trusted certs from a directory + atlasCAPathEnvVar = "ATLAS_CAPATH" + // atlasTokenHeader is the header key used for authenticating with Atlas atlasTokenHeader = "X-Atlas-Token" ) @@ -112,6 +122,17 @@ func NewClient(urlString string) (*Client, error) { // init() sets defaults on the client. func (c *Client) init() error { c.HTTPClient = cleanhttp.DefaultClient() + tlsConfig := &tls.Config{} + err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{ + CAFile: os.Getenv(atlasCAFileEnvVar), + CAPath: os.Getenv(atlasCAPathEnvVar), + }) + if err != nil { + return err + } + t := cleanhttp.DefaultTransport() + t.TLSClientConfig = tlsConfig + c.HTTPClient.Transport = t return nil }