tls/acme: Return certmagic.New config in GetConfigForCert

Might have caused partially broken configurations e.g. #619.
This commit is contained in:
fox.cpp 2023-08-23 16:55:04 +03:00
parent b8ff1168a0
commit d9920f0763
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0

View file

@ -83,10 +83,7 @@ func (l *Loader) Init(cfg *config.Map) error {
l.cache = certmagic.NewCache(certmagic.CacheOptions{
Logger: cmLog,
GetConfigForCert: func(c certmagic.Certificate) (*certmagic.Config, error) {
return &certmagic.Config{
Storage: l.store,
Logger: cmLog,
}, nil
return l.cfg, nil
},
})
@ -95,7 +92,7 @@ func (l *Loader) Init(cfg *config.Map) error {
Logger: cmLog,
DefaultServerName: hostname,
})
mngr := certmagic.NewACMEIssuer(l.cfg, certmagic.ACMEIssuer{
issuer := certmagic.NewACMEIssuer(l.cfg, certmagic.ACMEIssuer{
Logger: cmLog,
CA: caPath,
Email: email,
@ -104,19 +101,19 @@ func (l *Loader) Init(cfg *config.Map) error {
switch challenge {
case "dns-01":
mngr.DisableTLSALPNChallenge = true
mngr.DisableHTTPChallenge = true
issuer.DisableTLSALPNChallenge = true
issuer.DisableHTTPChallenge = true
if provider == nil {
return fmt.Errorf("tls.loader.acme: dns-01 challenge requires a configured DNS provider")
}
mngr.DNS01Solver = &certmagic.DNS01Solver{
issuer.DNS01Solver = &certmagic.DNS01Solver{
DNSProvider: provider,
OverrideDomain: overrideDomain,
}
default:
return fmt.Errorf("tls.loader.acme: challenge not supported")
}
l.cfg.Issuers = []certmagic.Issuer{mngr}
l.cfg.Issuers = []certmagic.Issuer{issuer}
if module.NoRun {
return nil