mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-09 09:36:58 +01:00
https: Wait as long as possible to create ACME client at startup (fixes #617)
This commit is contained in:
parent
ecf913e58d
commit
09a7af8cae
1 changed files with 14 additions and 4 deletions
|
@ -117,16 +117,26 @@ func ObtainCerts(configs []server.Config, allowPrompts, proxyACME bool) error {
|
||||||
groupedConfigs := groupConfigsByEmail(configs, allowPrompts)
|
groupedConfigs := groupConfigsByEmail(configs, allowPrompts)
|
||||||
|
|
||||||
for email, group := range groupedConfigs {
|
for email, group := range groupedConfigs {
|
||||||
client, err := NewACMEClient(email, allowPrompts)
|
// Wait as long as we can before creating the client, because it
|
||||||
if err != nil {
|
// may not be needed, for example, if we already have what we
|
||||||
return errors.New("error creating client: " + err.Error())
|
// need on disk. Creating a client involves the network and
|
||||||
}
|
// potentially prompting the user, etc., so only do if necessary.
|
||||||
|
var client *ACMEClient
|
||||||
|
|
||||||
for _, cfg := range group {
|
for _, cfg := range group {
|
||||||
if cfg.Host == "" || existingCertAndKey(cfg.Host) {
|
if cfg.Host == "" || existingCertAndKey(cfg.Host) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now we definitely do need a client
|
||||||
|
if client == nil {
|
||||||
|
var err error
|
||||||
|
client, err = NewACMEClient(email, allowPrompts)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("error creating client: " + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// c.Configure assumes that allowPrompts == !proxyACME,
|
// c.Configure assumes that allowPrompts == !proxyACME,
|
||||||
// but that's not always true. For example, a restart where
|
// but that's not always true. For example, a restart where
|
||||||
// the user isn't present and we're not listening on port 80.
|
// the user isn't present and we're not listening on port 80.
|
||||||
|
|
Loading…
Reference in a new issue