Browse Source
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
master
Matthew Holt
5 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with
12 additions and
10 deletions
-
cmd/commandfuncs.go
-
cmd/main.go
|
@ -35,7 +35,6 @@ import ( |
|
|
"github.com/caddyserver/caddy/v2" |
|
|
"github.com/caddyserver/caddy/v2" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" |
|
|
"github.com/caddyserver/certmagic" |
|
|
|
|
|
"go.uber.org/zap" |
|
|
"go.uber.org/zap" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -184,15 +183,6 @@ func cmdRun(fl Flags) (int, error) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
|
|
|
|
|
|
|
// run the initial config
|
|
|
// run the initial config
|
|
|
err = caddy.Load(config, true) |
|
|
err = caddy.Load(config, true) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
@ -30,9 +30,21 @@ import ( |
|
|
|
|
|
|
|
|
"github.com/caddyserver/caddy/v2" |
|
|
"github.com/caddyserver/caddy/v2" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig" |
|
|
"github.com/caddyserver/caddy/v2/caddyconfig" |
|
|
|
|
|
"github.com/caddyserver/certmagic" |
|
|
"go.uber.org/zap" |
|
|
"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.
|
|
|
// Main implements the main function of the caddy command.
|
|
|
// Call this if Caddy is to be the main() if your program.
|
|
|
// Call this if Caddy is to be the main() if your program.
|
|
|
func Main() { |
|
|
func Main() { |
|
|