From 4b4e16edafd62fe0d9510987984ed26c981e84da Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 23 Mar 2020 14:43:42 -0600 Subject: cmd: Ensure certmagic defaults are set for any and all subcommands This is really crucial and I'm surprised no one reported a problem yet --- cmd/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cmd/main.go') diff --git a/cmd/main.go b/cmd/main.go index 4dbbe38..bdc95a4 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -30,9 +30,21 @@ import ( "github.com/caddyserver/caddy/v2" "github.com/caddyserver/caddy/v2/caddyconfig" + "github.com/caddyserver/certmagic" "go.uber.org/zap" ) +func init() { + // set a fitting User-Agent for ACME requests + goModule := caddy.GoModule() + cleanModVersion := strings.TrimPrefix(goModule.Version, "v") + certmagic.UserAgent = "Caddy/" + cleanModVersion + + // by using Caddy, user indicates agreement to CA terms + // (very important, or ACME account creation will fail!) + certmagic.DefaultACME.Agreed = true +} + // Main implements the main function of the caddy command. // Call this if Caddy is to be the main() if your program. func Main() { -- cgit v1.2.3