mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-24 16:59:00 +01:00
Ignore conflicting settings if TLS disabled (fixes #1075)
This commit is contained in:
parent
191ec27c26
commit
34a99598f7
2 changed files with 19 additions and 1 deletions
|
@ -338,6 +338,10 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
|
||||||
configs[i-1].Hostname, lastConfProto, cfg.Hostname, thisConfProto)
|
configs[i-1].Hostname, lastConfProto, cfg.Hostname, thisConfProto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !cfg.Enabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Union cipher suites
|
// Union cipher suites
|
||||||
for _, ciph := range cfg.Ciphers {
|
for _, ciph := range cfg.Ciphers {
|
||||||
if _, ok := ciphersAdded[ciph]; !ok {
|
if _, ok := ciphersAdded[ciph]; !ok {
|
||||||
|
@ -348,7 +352,7 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
|
||||||
|
|
||||||
// Can't resolve conflicting PreferServerCipherSuites settings
|
// Can't resolve conflicting PreferServerCipherSuites settings
|
||||||
if i > 0 && cfg.PreferServerCipherSuites != configs[i-1].PreferServerCipherSuites {
|
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
|
config.PreferServerCipherSuites = cfg.PreferServerCipherSuites
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,20 @@ func TestMakeTLSConfigPreferServerCipherSuites(t *testing.T) {
|
||||||
if got, want := result.PreferServerCipherSuites, true; got != want {
|
if got, want := result.PreferServerCipherSuites, true; got != want {
|
||||||
t.Errorf("Expected PreferServerCipherSuites==%v but got %v", want, got)
|
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) {
|
func TestMakeTLSConfigTLSEnabledDisabled(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue