Skip to content

Commit 8d92ff9

Browse files
committed
Configurable propagation checks in DNS solver
Lots of users over the years have reported that the propagation checks time out, yet the challenges would/did still succeed. Example: https://caddy.community/t/hard-time-getting-a-response-on-a-dns-01-challenge/15721?u=matt We are not sure why this happens, but it seems prudent to be able to disable or delay the propagation checks.
1 parent 03cffeb commit 8d92ff9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

solvers.go

+25-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,13 @@ type DNS01Solver struct {
249249
// The TTL for the temporary challenge records.
250250
TTL time.Duration
251251

252-
// Maximum time to wait for temporary record to appear.
252+
// How long to wait before starting propagation checks.
253+
// Default: 0 (no wait).
254+
PropagationDelay time.Duration
255+
256+
// Maximum time to wait for temporary DNS record to appear.
257+
// Set to -1 to disable propagation checks.
258+
// Default: 2 minutes.
253259
PropagationTimeout time.Duration
254260

255261
// Preferred DNS resolver(s) to use when doing DNS lookups.
@@ -314,18 +320,36 @@ func (s *DNS01Solver) Present(ctx context.Context, challenge acme.Challenge) err
314320
// authoritative lookups, i.e. until it has propagated, or until
315321
// timeout, whichever is first.
316322
func (s *DNS01Solver) Wait(ctx context.Context, challenge acme.Challenge) error {
323+
// if configured to, pause before doing propagation checks
324+
// (even if they are disabled, the wait might be desirable on its own)
325+
if s.PropagationDelay > 0 {
326+
select {
327+
case <-time.After(s.PropagationDelay):
328+
case <-ctx.Done():
329+
return ctx.Err()
330+
}
331+
}
332+
333+
// skip propagation checks if configured to do so
334+
if s.PropagationTimeout == -1 {
335+
return nil
336+
}
337+
338+
// prepare for the checks by determining what to look for
317339
dnsName := challenge.DNS01TXTRecordName()
318340
if s.OverrideDomain != "" {
319341
dnsName = s.OverrideDomain
320342
}
321343
keyAuth := challenge.DNS01KeyAuthorization()
322344

345+
// timings
323346
timeout := s.PropagationTimeout
324347
if timeout == 0 {
325348
timeout = 2 * time.Minute
326349
}
327350
const interval = 2 * time.Second
328351

352+
// how we'll do the checks
329353
resolvers := recursiveNameservers(s.Resolvers)
330354

331355
var err error

0 commit comments

Comments
 (0)