Skip to content

Commit

Permalink
Merge pull request #2587 from weargoggles/patch-1
Browse files Browse the repository at this point in the history
Verification options for TLS
  • Loading branch information
schmichael committed May 2, 2017
2 parents ba73ed5 + b16409a commit d227780
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions command/agent/config-test-fixtures/basic.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ tls {
ca_file = "foo"
cert_file = "bar"
key_file = "pipe"
verify_https_client = true
}
1 change: 1 addition & 0 deletions command/agent/config_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ func parseTLSConfig(result **config.TLSConfig, list *ast.ObjectList) error {
"ca_file",
"cert_file",
"key_file",
"verify_https_client",
}

if err := checkHCLKeys(listVal, valid); err != nil {
Expand Down
1 change: 1 addition & 0 deletions command/agent/config_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func TestConfig_Parse(t *testing.T) {
CAFile: "foo",
CertFile: "bar",
KeyFile: "pipe",
VerifyHTTPSClient: true,
},
HTTPAPIResponseHeaders: map[string]string{
"Access-Control-Allow-Origin": "*",
Expand Down
2 changes: 1 addition & 1 deletion command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewHTTPServer(agent *Agent, config *Config) (*HTTPServer, error) {
// If TLS is enabled, wrap the listener with a TLS listener
if config.TLSConfig.EnableHTTP {
tlsConf := &tlsutil.Config{
VerifyIncoming: false,
VerifyIncoming: config.TLSConfig.VerifyHTTPSClient,
VerifyOutgoing: true,
VerifyServerHostname: config.TLSConfig.VerifyServerHostname,
CAFile: config.TLSConfig.CAFile,
Expand Down
7 changes: 6 additions & 1 deletion nomad/structs/config/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type TLSConfig struct {
// KeyFile is used to provide a TLS key that is used for serving TLS connections.
// Must be provided to serve TLS connections.
KeyFile string `mapstructure:"key_file"`

// Verify connections to the HTTPS API
VerifyHTTPSClient bool `mapstructure:"verify_https_client"`
}

// Merge is used to merge two TLS configs together
Expand All @@ -52,6 +55,8 @@ func (t *TLSConfig) Merge(b *TLSConfig) *TLSConfig {
if b.KeyFile != "" {
result.KeyFile = b.KeyFile
}

if b.VerifyHTTPSClient {
result.VerifyHTTPSClient = true
}
return &result
}

0 comments on commit d227780

Please sign in to comment.