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

make insecure TLS settings a config option #254

Merged
merged 1 commit into from
May 17, 2021
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
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type Config interface {
// use for peer management.
GetUseTLS() (bool, error)

// UseTLSInsecure returns true when certificate checks are disabled
GetUseTLSInsecure() (bool, error)

// GetHoneycombAPI returns the base URL (protocol, hostname, and port) of
// the upstream Honeycomb API server
GetHoneycombAPI() (string, error)
Expand Down
9 changes: 9 additions & 0 deletions config/file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type PeerManagementConfig struct {
RedisHost string
RedisPassword string
UseTLS bool
UseTLSInsecure bool
IdentifierInterfaceName string
UseIPV6Identifier bool
RedisIdentifier string
Expand All @@ -132,6 +133,7 @@ func NewConfig(config, rules string, errorCallback func(error)) (Config, error)
c.SetDefault("PeerManagement.Peers", []string{"http://127.0.0.1:8081"})
c.SetDefault("PeerManagement.Type", "file")
c.SetDefault("PeerManagement.UseTLS", false)
c.SetDefault("PeerManagement.UseTLSInsecure", false)
c.SetDefault("PeerManagement.UseIPV6Identifier", false)
c.SetDefault("HoneycombAPI", "https://api.honeycomb.io")
c.SetDefault("Logger", "logrus")
Expand Down Expand Up @@ -452,6 +454,13 @@ func (f *fileConfig) GetUseTLS() (bool, error) {
return f.config.GetBool("PeerManagement.UseTLS"), nil
}

func (f *fileConfig) GetUseTLSInsecure() (bool, error) {
f.mux.RLock()
defer f.mux.RUnlock()

return f.config.GetBool("PeerManagement.UseTLSInsecure"), nil
}

func (f *fileConfig) GetIdentifierInterfaceName() (string, error) {
f.mux.RLock()
defer f.mux.RUnlock()
Expand Down
8 changes: 8 additions & 0 deletions config/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type MockConfig struct {
GetRedisPasswordVal string
GetUseTLSErr error
GetUseTLSVal bool
GetUseTLSInsecureErr error
GetUseTLSInsecureVal bool
GetSamplerTypeErr error
GetSamplerTypeVal interface{}
GetMetricsTypeErr error
Expand Down Expand Up @@ -182,6 +184,12 @@ func (m *MockConfig) GetUseTLS() (bool, error) {

return m.GetUseTLSVal, m.GetUseTLSErr
}
func (m *MockConfig) GetUseTLSInsecure() (bool, error) {
m.Mux.RLock()
defer m.Mux.RUnlock()

return m.GetUseTLSInsecureVal, m.GetUseTLSInsecureErr
}
func (m *MockConfig) GetMetricsType() (string, error) {
m.Mux.RLock()
defer m.Mux.RUnlock()
Expand Down
4 changes: 4 additions & 0 deletions config_complete.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ Metrics = "honeycomb"
# Not eligible for live reload.
# UseTLS = false

# UseTLSInsecure disables certificate checks
# Not eligible for live reload.
# UseTLSInsecure = false

# IdentifierInterfaceName is optional. By default, when using RedisHost, Refinery will use
# the local hostname to identify itself to other peers in Redis. If your environment
# requires that you use IPs as identifiers (for example, if peers can't resolve eachother
Expand Down
7 changes: 6 additions & 1 deletion internal/peer/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,18 @@ func buildOptions(c config.Config) []redis.DialOption {
}

useTLS, _ := c.GetUseTLS()
tlsInsecure, _ := c.GetUseTLSInsecure()
if useTLS {
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
}

if tlsInsecure {
tlsConfig.InsecureSkipVerify = true
}

options = append(options,
redis.DialTLSConfig(tlsConfig),
redis.DialTLSSkipVerify(true),
redis.DialUseTLS(true))
}

Expand Down