Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement the On-Demand TLS feature #63

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove debugging statements and old code
  • Loading branch information
did committed Nov 1, 2024
commit 2a30eb856ee8e28d4b5626d1d7cdb826ef1e2b88
31 changes: 0 additions & 31 deletions internal/server/service.go
Original file line number Diff line number Diff line change
@@ -322,37 +322,6 @@ func (s *Service) createCertManager(hosts []string, options ServiceOptions) (Cer
}
}

// // TODO:
// // - create a func instead to return the host policy
// // - create the function calling the on demand url
// var hostPolicy = autocert.HostWhitelist(hosts...)

// // https://stackoverflow.com/questions/52129908/can-i-have-a-dynamic-host-policty-with-autocert

// // Wildcard hosts!!! we can handle them now!
// if len(hosts) == 0 && options.TLSOnDemandUrl != "" {
// fmt.Println("🚀🚀🚀 Registering a custom hostPolicy for", hosts)
// hostPolicy = func(ctx context.Context, host string) error {
// slog.Debug("Contacting", options.TLSOnDemandUrl, host)

// resp, err := http.Get(fmt.Sprintf("%s?domain=%s", options.TLSOnDemandUrl, url.QueryEscape(host)))

// if err != nil {
// // the TLS on demand URL is not reachable
// slog.Error("Unable to reach the TLS on demand URL", host, err)
// return err
// }

// if resp.StatusCode != 200 && resp.StatusCode != 201 {
// return fmt.Errorf("%s is not allowed to get a certificate", host)
// }

// return nil
// }
// } else {
// fmt.Println("😕😕😕", len(hosts), hosts, options.TLSOnDemandUrl)
// }

hostPolicy, err := s.createAutoCertHostPolicy(hosts, options)

did marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {