prevent panic when starting with a mox.conf that references an ACME provider that isn't configured

the error handling code attempts to collect all error messages it encounters,
to print them all at the end, so you can fix them all before trying again. so
we try to continue preparing the config after an error. in this case, we
continued as if acme.Manager was properly set and nil-dereferenced it.

for issue #2, from hismailbulut
This commit is contained in:
Mechiel Lukkien 2023-02-21 23:06:11 +01:00
parent cc3a2c9bc8
commit 8affa12c39
No known key found for this signature in database

View file

@ -431,10 +431,10 @@ func PrepareStaticConfig(ctx context.Context, configFile string, config *Config,
addErrorf("listener %q: unknown ACME provider %q", name, l.TLS.ACME) addErrorf("listener %q: unknown ACME provider %q", name, l.TLS.ACME)
} }
// If only checking, we don't have an acme manager, so set an empty tls config to // If only checking or with missing ACME definition, we don't have an acme manager,
// continue without errors. // so set an empty tls config to continue.
var tlsconfig *tls.Config var tlsconfig *tls.Config
if checkOnly { if checkOnly || acme.Manager == nil {
tlsconfig = &tls.Config{} tlsconfig = &tls.Config{}
} else { } else {
tlsconfig = acme.Manager.TLSConfig.Clone() tlsconfig = acme.Manager.TLSConfig.Clone()