Commit 34a99598 authored by Matthew Holt's avatar Matthew Holt

Ignore conflicting settings if TLS disabled (fixes #1075)

parent 191ec27c
......@@ -338,6 +338,10 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
configs[i-1].Hostname, lastConfProto, cfg.Hostname, thisConfProto)
}
if !cfg.Enabled {
continue
}
// Union cipher suites
for _, ciph := range cfg.Ciphers {
if _, ok := ciphersAdded[ciph]; !ok {
......@@ -348,7 +352,7 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
// Can't resolve conflicting PreferServerCipherSuites settings
if i > 0 && cfg.PreferServerCipherSuites != configs[i-1].PreferServerCipherSuites {
return nil, fmt.Errorf("cannot both use PreferServerCipherSuites and not use it")
return nil, fmt.Errorf("cannot both PreferServerCipherSuites and not prefer them")
}
config.PreferServerCipherSuites = cfg.PreferServerCipherSuites
......
......@@ -39,6 +39,20 @@ func TestMakeTLSConfigPreferServerCipherSuites(t *testing.T) {
if got, want := result.PreferServerCipherSuites, true; got != want {
t.Errorf("Expected PreferServerCipherSuites==%v but got %v", want, got)
}
// make sure we don't get an error if there's a conflict
// when both of the configs have TLS disabled
configs = []*Config{
{Enabled: false, PreferServerCipherSuites: false},
{Enabled: false, PreferServerCipherSuites: true},
}
result, err = MakeTLSConfig(configs)
if err != nil {
t.Fatalf("Did not expect an error when TLS is disabled, but got '%v'", err)
}
if result != nil {
t.Errorf("Expected nil result because TLS disabled, got: %+v", err)
}
}
func TestMakeTLSConfigTLSEnabledDisabled(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment