@marcel91200 / caddy Mirror · read-only / commits / 77a77c02
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 19:15 UTC

caddytls: Add `propagation_delay`, support `propagation_timeout -1` (#4723)

Francis Lavoie committed Apr 22, 2022 at 18:09 UTC 77a77c0219d389717ba3b8f8e28bad3462fab655
5 files changed +60 -11
caddytest/integration/caddyfile_adapt/tls_propagation_timeout.txt
+17 -2
@@ -3,7 +3,12 @@ localhost
3 respond "hello from localhost"
4 tls {
5 issuer acme {
6 - propagation_timeout "10m0s"
6 + propagation_delay 5m10s
7 + propagation_timeout 10m20s
8 + }
9 + issuer zerossl {
10 + propagation_delay 5m30s
11 + propagation_timeout -1
12 }
13 }
14 ----------
@@ -56,10 +61,20 @@ tls {
61 {
62 "challenges": {
63 "dns": {
59 - "propagation_timeout": 600000000000
64 + "propagation_delay": 310000000000,
65 + "propagation_timeout": 620000000000
66 }
67 },
68 "module": "acme"
69 + },
70 + {
71 + "challenges": {
72 + "dns": {
73 + "propagation_delay": 330000000000,
74 + "propagation_timeout": -1
75 + }
76 + },
77 + "module": "zerossl"
78 }
79 ]
80 }
go.mod
+1 -1
@@ -7,7 +7,7 @@ require (
7 github.com/Masterminds/sprig/v3 v3.2.2
8 github.com/alecthomas/chroma v0.10.0
9 github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
10 - github.com/caddyserver/certmagic v0.16.0
10 + github.com/caddyserver/certmagic v0.16.1
11 github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
12 github.com/go-chi/chi v4.1.2+incompatible
13 github.com/google/cel-go v0.7.3
go.sum
+2 -2
@@ -199,8 +199,8 @@ github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl
199 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
200 github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
201 github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw=
202 -github.com/caddyserver/certmagic v0.16.0 h1:nM6Fm+OSnTpx/uRWmN++I2fYq006uhi6m6m3rD1Jjtg=
203 -github.com/caddyserver/certmagic v0.16.0/go.mod h1:jKQ5n+ViHAr6DbPwEGLTSM2vDwTO6EvCKBblBRUvvuQ=
202 +github.com/caddyserver/certmagic v0.16.1 h1:rdSnjcUVJojmL4M0efJ+yHXErrrijS4YYg3FuwRdJkI=
203 +github.com/caddyserver/certmagic v0.16.1/go.mod h1:jKQ5n+ViHAr6DbPwEGLTSM2vDwTO6EvCKBblBRUvvuQ=
204 github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e/go.mod h1:9IOqJGCPMSc6E5ydlp5NIonxObaeu/Iub/X03EKPVYo=
205 github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
206 github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oDpT4efm8tSYHXV5tHSdRvBet/b/QzxZ+XyyPehvm3A=
modules/caddytls/acmeissuer.go
+33 -5
@@ -142,6 +142,7 @@ func (iss *ACMEIssuer) Provision(ctx caddy.Context) error {
142 iss.Challenges.DNS.solver = &certmagic.DNS01Solver{
143 DNSProvider: val.(certmagic.ACMEDNSProvider),
144 TTL: time.Duration(iss.Challenges.DNS.TTL),
145 + PropagationDelay: time.Duration(iss.Challenges.DNS.PropagationDelay),
146 PropagationTimeout: time.Duration(iss.Challenges.DNS.PropagationTimeout),
147 Resolvers: iss.Challenges.DNS.Resolvers,
148 OverrideDomain: iss.Challenges.DNS.OverrideDomain,
@@ -262,10 +263,13 @@ func (iss *ACMEIssuer) GetACMEIssuer() *ACMEIssuer { return iss }
263 // eab <key_id> <mac_key>
264 // trusted_roots <pem_files...>
265 // dns <provider_name> [<options>]
266 +// propagation_delay <duration>
267 +// propagation_timeout <duration>
268 // resolvers <dns_servers...>
269 +// dns_challenge_override_domain <domain>
270 // preferred_chains [smallest] {
267 -// root_common_name <common_names...>
268 -// any_common_name <common_names...>
271 +// root_common_name <common_names...>
272 +// any_common_name <common_names...>
273 // }
274 // }
275 //
@@ -389,14 +393,38 @@ func (iss *ACMEIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
393 return err
394 }
395 iss.Challenges.DNS.ProviderRaw = caddyconfig.JSONModuleObject(unm, "name", provName, nil)
396 +
397 + case "propagation_delay":
398 + if !d.NextArg() {
399 + return d.ArgErr()
400 + }
401 + delayStr := d.Val()
402 + delay, err := caddy.ParseDuration(delayStr)
403 + if err != nil {
404 + return d.Errf("invalid propagation_delay duration %s: %v", delayStr, err)
405 + }
406 + if iss.Challenges == nil {
407 + iss.Challenges = new(ChallengesConfig)
408 + }
409 + if iss.Challenges.DNS == nil {
410 + iss.Challenges.DNS = new(DNSChallengeConfig)
411 + }
412 + iss.Challenges.DNS.PropagationDelay = caddy.Duration(delay)
413 +
414 case "propagation_timeout":
415 if !d.NextArg() {
416 return d.ArgErr()
417 }
418 timeoutStr := d.Val()
397 - timeout, err := caddy.ParseDuration(timeoutStr)
398 - if err != nil {
399 - return d.Errf("invalid propagation_timeout duration %s: %v", timeoutStr, err)
419 + var timeout time.Duration
420 + if timeoutStr == "-1" {
421 + timeout = time.Duration(-1)
422 + } else {
423 + var err error
424 + timeout, err = caddy.ParseDuration(timeoutStr)
425 + if err != nil {
426 + return d.Errf("invalid propagation_timeout duration %s: %v", timeoutStr, err)
427 + }
428 }
429 if iss.Challenges == nil {
430 iss.Challenges = new(ChallengesConfig)
modules/caddytls/automation.go
+7 -1
@@ -363,7 +363,13 @@ type DNSChallengeConfig struct {
363 // The TTL of the TXT record used for the DNS challenge.
364 TTL caddy.Duration `json:"ttl,omitempty"`
365
366 - // How long to wait for DNS record to propagate.
366 + // How long to wait before starting propagation checks.
367 + // Default: 0 (no wait).
368 + PropagationDelay caddy.Duration `json:"propagation_delay,omitempty"`
369 +
370 + // Maximum time to wait for temporary DNS record to appear.
371 + // Set to -1 to disable propagation checks.
372 + // Default: 2 minutes.
373 PropagationTimeout caddy.Duration `json:"propagation_timeout,omitempty"`
374
375 // Custom DNS resolvers to prefer over system/built-in defaults.