caddyserver / certmagic

Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal
https://pkg.go.dev/github.com/caddyserver/certmagic?tab=doc
Apache License 2.0
5.03k stars 293 forks source link

Check TOS #164

Open LecrisUT opened 2 years ago

LecrisUT commented 2 years ago

What would you like to have changed?

Either expose ACMEManager.newACMEClientWithAccount, add this initialization in ACMEManager.PreCheck with the same interactive flag, or add a new function altogether to manually InitializeAccount.

Why is this feature a useful, necessary, and/or important addition to this project?

The goal is to have a check whether or not the cached account has accepted the TOS, or if in interative mode, prompt the user to accept/decline with the link to the TOS. Fetching and exposing the Acme meta directory would also be useful. I am nut sure which approach makes more sense in the given flow, but I am leaning towards separating the TOS code in https://github.com/caddyserver/certmagic/blob/b6b3db32bcd5f87d56bc0fba1db708499259653a/acmeclient.go#L70-L123 and adding another function to initialize the account (interactively, error if not accepted) or check Account.TermsOfServiceAgreed if already exists.

I will try to write a PR with this idea if you think it's ok.

mholt commented 2 years ago

Interesting; why do you need this?

LecrisUT commented 2 years ago

In go-gitea/gitea#18340, I am decoupling the letsencrypt TOS and generalizing to arbitrary ones defined in the directory meta. So I want to link them to the TOS if the default of not accepting TOS is on, and offer a first-time interactive option to read and accept them, similar to PreCheck.