mirror of
https://github.com/go-acme/lego.git
synced 2024-12-23 01:07:23 +02:00
acmedns: fix CNAME support (#1847)
This commit is contained in:
parent
1e2793f9ec
commit
56fda1abd8
@ -102,21 +102,25 @@ func (e ErrCNAMERequired) Error() string {
|
|||||||
// one will be created and registered with the ACME DNS server and an ErrCNAMERequired error is returned.
|
// one will be created and registered with the ACME DNS server and an ErrCNAMERequired error is returned.
|
||||||
// This will halt issuance and indicate to the user that a one-time manual setup is required for the domain.
|
// This will halt issuance and indicate to the user that a one-time manual setup is required for the domain.
|
||||||
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||||
// Compute the challenge response FQDN and TXT value for the domain based
|
// Compute the challenge response FQDN and TXT value for the domain based on the keyAuth.
|
||||||
// on the keyAuth.
|
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
// Check if credentials were previously saved for this domain.
|
effectiveDomain := domain
|
||||||
// TODO(ldez) replace domain by FQDN to follow CNAME.
|
if isCNAME(domain, fqdn) {
|
||||||
account, err := d.storage.Fetch(domain)
|
effectiveDomain = fqdn
|
||||||
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
|
|
||||||
if err != nil && !errors.Is(err, goacmedns.ErrDomainNotFound) {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if errors.Is(err, goacmedns.ErrDomainNotFound) {
|
|
||||||
// The account did not exist. Create a new one and return an error
|
// Check if credentials were previously saved for this domain.
|
||||||
// indicating the required one-time manual CNAME setup.
|
account, err := d.storage.Fetch(effectiveDomain)
|
||||||
return d.register(domain, fqdn)
|
if err != nil {
|
||||||
|
if errors.Is(err, goacmedns.ErrDomainNotFound) {
|
||||||
|
// The account did not exist.
|
||||||
|
// Create a new one and return an error indicating the required one-time manual CNAME setup.
|
||||||
|
return d.register(effectiveDomain, fqdn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the acme-dns TXT record.
|
// Update the acme-dns TXT record.
|
||||||
@ -161,3 +165,7 @@ func (d *DNSProvider) register(domain, fqdn string) error {
|
|||||||
Target: newAcct.FullDomain,
|
Target: newAcct.FullDomain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isCNAME(domain, fqdn string) bool {
|
||||||
|
return fmt.Sprintf("_acme-challenge.%s.", domain) != fqdn
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user