Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification options for TLS #2587

Merged
merged 8 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}