Skip to content

Commit

Permalink
Merge pull request #1131 from rmt/master
Browse files Browse the repository at this point in the history
Add VAULT_TLS_SERVER_NAME environment variable
  • Loading branch information
jefferai committed Feb 25, 2016
2 parents 2f79bb1 + b906f22 commit 8970f3a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const EnvVaultCAPath = "VAULT_CAPATH"
const EnvVaultClientCert = "VAULT_CLIENT_CERT"
const EnvVaultClientKey = "VAULT_CLIENT_KEY"
const EnvVaultInsecure = "VAULT_SKIP_VERIFY"
const EnvVaultTLSServerName = "VAULT_TLS_SERVER_NAME"

var (
errRedirect = errors.New("redirect")
Expand Down Expand Up @@ -81,6 +82,7 @@ func (c *Config) ReadEnvironment() error {
var envClientKey string
var envInsecure bool
var foundInsecure bool
var envTLSServerName string

var newCertPool *x509.CertPool
var clientCert tls.Certificate
Expand Down Expand Up @@ -109,6 +111,9 @@ func (c *Config) ReadEnvironment() error {
}
foundInsecure = true
}
if v := os.Getenv(EnvVaultTLSServerName); v != "" {
envTLSServerName = v
}
// If we need custom TLS configuration, then set it
if envCACert != "" || envCAPath != "" || envClientCert != "" || envClientKey != "" || envInsecure {
var err error
Expand Down Expand Up @@ -146,6 +151,9 @@ func (c *Config) ReadEnvironment() error {
if foundClientCert {
clientTLSConfig.Certificates = []tls.Certificate{clientCert}
}
if envTLSServerName != "" {
clientTLSConfig.ServerName = envTLSServerName
}

return nil
}
Expand Down

0 comments on commit 8970f3a

Please sign in to comment.