Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OverrideDomain is DNS01Solver #160

Merged
merged 3 commits into from Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions dnsutil.go
Expand Up @@ -214,21 +214,11 @@ func checkDNSPropagation(fqdn, value string, resolvers []string) (bool, error) {
fqdn += "."
}

// Initial attempt to resolve at the recursive NS
r, err := dnsQuery(fqdn, dns.TypeTXT, resolvers, true)
if err != nil {
return false, err
}

// TODO: make this configurable, maybe
// if !p.requireCompletePropagation {
// return true, nil
// }

if r.Rcode == dns.RcodeSuccess {
fqdn = updateDomainWithCName(r, fqdn)
}

mholt marked this conversation as resolved.
Show resolved Hide resolved
authoritativeNss, err := lookupNameservers(fqdn, resolvers)
if err != nil {
return false, err
Expand Down
11 changes: 11 additions & 0 deletions solvers.go
Expand Up @@ -252,13 +252,21 @@ type DNS01Solver struct {
// Preferred DNS resolver(s) to use when doing DNS lookups.
Resolvers []string

// Override the domain to set the TXT record on. This is
// to delegate the chanllenge to a different domain. Note
mholt marked this conversation as resolved.
Show resolved Hide resolved
// that the solver doesn't follow CNAME/NS record.
OverrideDomain string

txtRecords map[string]dnsPresentMemory // keyed by domain name
txtRecordsMu sync.Mutex
}

// Present creates the DNS TXT record for the given ACME challenge.
func (s *DNS01Solver) Present(ctx context.Context, challenge acme.Challenge) error {
dnsName := challenge.DNS01TXTRecordName()
if s.OverrideDomain != "" {
dnsName = s.OverrideDomain
}
keyAuth := challenge.DNS01KeyAuthorization()

// multiple identifiers can have the same ACME challenge
Expand Down Expand Up @@ -304,6 +312,9 @@ func (s *DNS01Solver) Present(ctx context.Context, challenge acme.Challenge) err
// timeout, whichever is first.
func (s *DNS01Solver) Wait(ctx context.Context, challenge acme.Challenge) error {
dnsName := challenge.DNS01TXTRecordName()
if s.OverrideDomain != "" {
dnsName = s.OverrideDomain
}
keyAuth := challenge.DNS01KeyAuthorization()

timeout := s.PropagationTimeout
Expand Down