fix dns01 challenge
Alan Pearce alan@alanpearce.eu
Thu, 11 Jul 2024 11:02:10 +0200
1 files changed, 16 insertions(+), 12 deletions(-)
jump to
M internal/server/tls.go → internal/server/tls.go
@@ -40,10 +40,7 @@ certmagic.Default.Logger = log.GetLogger().Named("certmagic") cfg := certmagic.NewDefault() cfg.DefaultServerName = s.config.Domains[0] - issuer := &certmagic.DefaultACME - certmagic.DefaultACME.Agreed = true - certmagic.DefaultACME.Email = s.config.Email - certmagic.DefaultACME.Logger = certmagic.Default.Logger + var issuer *certmagic.ACMEIssuer if s.runtimeConfig.Development { ca := s.runtimeConfig.ACMECA @@ -71,8 +68,8 @@ DisableTLSALPNChallenge: true, ListenHost: s.runtimeConfig.ListenAddress, AltHTTPPort: s.runtimeConfig.Port, AltTLSALPNPort: s.runtimeConfig.TLSPort, + Logger: certmagic.Default.Logger, }) - cfg.Issuers[0] = issuer } else { rc := &redisConfig{} _, err = conf.Parse("REDIS", rc) @@ -86,14 +83,20 @@ if err != nil { return errors.Wrap(err, "could not parse ACME config") } - issuer.DNS01Solver = &certmagic.DNS01Solver{ - DNSManager: certmagic.DNSManager{ - DNSProvider: acme, - Logger: certmagic.Default.Logger, + issuer = certmagic.NewACMEIssuer(cfg, certmagic.ACMEIssuer{ + CA: certmagic.LetsEncryptProductionCA, + Email: s.config.Email, + Agreed: true, + Logger: certmagic.Default.Logger, + DNS01Solver: &certmagic.DNS01Solver{ + DNSManager: certmagic.DNSManager{ + DNSProvider: acme, + Logger: certmagic.Default.Logger, + }, }, - } + }) - log.Debug("acme", "username", acme.Username, "subdomain", acme.Subdomain, "server_url", acme.ServerURL) + log.Info("acme", "username", acme.Username, "subdomain", acme.Subdomain, "server_url", acme.ServerURL) rs := certmagic_redis.New() rs.Address = []string{rc.Address} @@ -110,6 +113,7 @@ if err != nil { return errors.Wrap(err, "could not provision redis storage") } } + cfg.Issuers[0] = issuer ln, err := listenfd.GetListener( 1, @@ -160,7 +164,7 @@ s.runtimeConfig.Port, "https_port", s.runtimeConfig.TLSPort, ) - err = cfg.ManageSync(context.TODO(), s.config.Domains) + err = cfg.ManageAsync(context.TODO(), append(s.config.Domains, "*.aln.pe")) if err != nil { return errors.Wrap(err, "could not enable TLS") }