From 2e0ef399e4f3dcc1fb7e7cbb8f217e3f522200f0 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Sat, 30 Nov 2024 15:16:34 +0100 Subject: [PATCH] don't check for the len of hosts when evaluating the TLSOnDemandUrl --- internal/server/service.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/server/service.go b/internal/server/service.go index 4ffadc8..864d2f6 100644 --- a/internal/server/service.go +++ b/internal/server/service.go @@ -337,9 +337,9 @@ func (s *Service) createCertManager(hosts []string, options ServiceOptions) (Cer } func (s *Service) createAutoCertHostPolicy(hosts []string, options ServiceOptions) (autocert.HostPolicy, error) { - onDemandTls := len(hosts) == 0 && options.TLSOnDemandUrl != "" + slog.Info("createAutoCertHostPolicy called", options.TLSOnDemandUrl, len(hosts), "🚨", "ok") - if !onDemandTls { + if options.TLSOnDemandUrl == "" { return autocert.HostWhitelist(hosts...), nil } @@ -350,7 +350,11 @@ func (s *Service) createAutoCertHostPolicy(hosts []string, options ServiceOption return nil, err } + slog.Info("Will use the tls_on_demand_url URL") + return func(ctx context.Context, host string) error { + slog.Info("Get a certificate for", host, "🤞") + resp, err := http.Get(fmt.Sprintf("%s?host=%s", options.TLSOnDemandUrl, url.QueryEscape(host))) if err != nil {