From 5e37ee3822b9b8f5d6ab4b5dfa4c9a2b90ed5530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Brunink?= <1129998+jbrunink@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:43:33 +0200 Subject: [PATCH] cname: stop trying to traverse cname if none have been found (#1733) Co-authored-by: Fernandez Ludovic --- challenge/dns01/dns_challenge.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/challenge/dns01/dns_challenge.go b/challenge/dns01/dns_challenge.go index ca24e7af..8e271e39 100644 --- a/challenge/dns01/dns_challenge.go +++ b/challenge/dns01/dns_challenge.go @@ -194,14 +194,18 @@ func getChallengeFqdn(domain string) string { // Keep following CNAMEs r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true) - // Check if the domain has CNAME then use that - if err == nil && r.Rcode == dns.RcodeSuccess { - fqdn = updateDomainWithCName(r, fqdn) - continue + if err != nil || r.Rcode != dns.RcodeSuccess { + // No more CNAME records to follow, exit + break } - // No more CNAME records to follow, exit - break + // Check if the domain has CNAME then use that + cname := updateDomainWithCName(r, fqdn) + if cname == fqdn { + break + } + + fqdn = cname } return fqdn