Skip to content

Commit

Permalink
don't check for the len of hosts when evaluating the TLSOnDemandUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Nov 30, 2024
1 parent f91ed90 commit 2e0ef39
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down

0 comments on commit 2e0ef39

Please sign in to comment.