Skip to content

Commit

Permalink
Add support to skip TLS verification
Browse files Browse the repository at this point in the history
Follow up from open-telemetry#933 where InsecureSkipVerify was discussed but not
implemented.
  • Loading branch information
bombsimon committed Nov 23, 2020
1 parent cc0a999 commit 15c9331
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/configtls/configtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ type TLSClientSetting struct {
// (InsecureSkipVerify in the tls Config). Please refer to
// https://godoc.org/crypto/tls#Config for more information.
// (optional, default false)
// TODO(ccaraman): With further research InsecureSkipVerify is a valid option
// for gRPC connections. Add that ability to the TLSClientSettings in a subsequent
// pr.
Insecure bool `mapstructure:"insecure"`
// InsecureSkipVerify will enable TLS but not verify the certificate.
InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
// ServerName requested by client for virtual hosting.
// This sets the ServerName in the TLSConfig. Please refer to
// https://godoc.org/crypto/tls#Config for more information. (optional)
Expand Down Expand Up @@ -131,6 +130,7 @@ func (c TLSClientSetting) LoadTLSConfig() (*tls.Config, error) {
return nil, fmt.Errorf("failed to load TLS config: %w", err)
}
tlsCfg.ServerName = c.ServerName
tlsCfg.InsecureSkipVerify = c.InsecureSkipVerify
return tlsCfg, nil
}

Expand Down
8 changes: 8 additions & 0 deletions config/configtls/configtls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ func TestLoadTLSClientConfig(t *testing.T) {
tlsCfg, err = tlsSetting.LoadTLSConfig()
assert.NoError(t, err)
assert.NotNil(t, tlsCfg)

tlsSetting = TLSClientSetting{
InsecureSkipVerify: true,
}
tlsCfg, err = tlsSetting.LoadTLSConfig()
assert.NoError(t, err)
assert.NotNil(t, tlsCfg)
assert.True(t, tlsCfg.InsecureSkipVerify)
}

func TestLoadTLSServerConfigError(t *testing.T) {
Expand Down

0 comments on commit 15c9331

Please sign in to comment.