diff --git a/providers/dns/acmedns/acmedns.go b/providers/dns/acmedns/acmedns.go index 40d6b96e..96f0aafc 100644 --- a/providers/dns/acmedns/acmedns.go +++ b/providers/dns/acmedns/acmedns.go @@ -107,6 +107,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) // Check if credentials were previously saved for this domain. + // TODO(ldez) replace domain by FQDN to follow CNAME. account, err := d.storage.Fetch(domain) // Errors other than goacmeDNS.ErrDomainNotFound are unexpected. if err != nil && !errors.Is(err, goacmedns.ErrDomainNotFound) { diff --git a/providers/dns/alidns/alidns.go b/providers/dns/alidns/alidns.go index 9a5d8169..339909bb 100644 --- a/providers/dns/alidns/alidns.go +++ b/providers/dns/alidns/alidns.go @@ -132,7 +132,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneName, err := d.getHostedZone(domain) + zoneName, err := d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("alicloud: %w", err) } @@ -153,12 +153,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) - records, err := d.findTxtRecords(domain, fqdn) + records, err := d.findTxtRecords(fqdn) if err != nil { return fmt.Errorf("alicloud: %w", err) } - _, err = d.getHostedZone(domain) + _, err = d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("alicloud: %w", err) } @@ -197,7 +197,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, error) { startPage++ } - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", err } @@ -233,8 +233,8 @@ func (d *DNSProvider) newTxtRecord(zone, fqdn, value string) (*alidns.AddDomainR return request, nil } -func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]alidns.Record, error) { - zoneName, err := d.getHostedZone(domain) +func (d *DNSProvider) findTxtRecords(fqdn string) ([]alidns.Record, error) { + zoneName, err := d.getHostedZone(fqdn) if err != nil { return nil, err } diff --git a/providers/dns/auroradns/auroradns.go b/providers/dns/auroradns/auroradns.go index 2e2870b2..bf980aeb 100644 --- a/providers/dns/auroradns/auroradns.go +++ b/providers/dns/auroradns/auroradns.go @@ -106,7 +106,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return fmt.Errorf("aurora: could not determine zone for domain %q: %w", domain, err) } @@ -158,7 +158,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("unknown recordID for %q", fqdn) } - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(fqdn)) if err != nil { return fmt.Errorf("could not determine zone for domain %q: %w", domain, err) } diff --git a/providers/dns/autodns/autodns.go b/providers/dns/autodns/autodns.go index 3db90574..afe3954f 100644 --- a/providers/dns/autodns/autodns.go +++ b/providers/dns/autodns/autodns.go @@ -114,6 +114,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Value: value, }} + // TODO(ldez) replace domain by FQDN to follow CNAME. _, err := d.addTxtRecord(domain, records) if err != nil { return fmt.Errorf("autodns: %w", err) @@ -133,6 +134,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { Value: value, }} + // TODO(ldez) replace domain by FQDN to follow CNAME. if err := d.removeTXTRecord(domain, records); err != nil { return fmt.Errorf("autodns: %w", err) } diff --git a/providers/dns/checkdomain/checkdomain.go b/providers/dns/checkdomain/checkdomain.go index e14bfa37..415ce46b 100644 --- a/providers/dns/checkdomain/checkdomain.go +++ b/providers/dns/checkdomain/checkdomain.go @@ -101,6 +101,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { + // TODO(ldez) replace domain by FQDN to follow CNAME. domainID, err := d.getDomainIDByName(domain) if err != nil { return fmt.Errorf("checkdomain: %w", err) @@ -111,10 +112,10 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { return fmt.Errorf("checkdomain: %w", err) } - name, value := dns01.GetRecord(domain, keyAuth) + fqdn, value := dns01.GetRecord(domain, keyAuth) err = d.createRecord(domainID, &Record{ - Name: name, + Name: fqdn, TTL: d.config.TTL, Type: "TXT", Value: value, @@ -129,6 +130,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record previously created. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + // TODO(ldez) replace domain by FQDN to follow CNAME. domainID, err := d.getDomainIDByName(domain) if err != nil { return fmt.Errorf("checkdomain: %w", err) @@ -139,15 +141,15 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("checkdomain: %w", err) } - name, value := dns01.GetRecord(domain, keyAuth) + fqdn, value := dns01.GetRecord(domain, keyAuth) - err = d.deleteTXTRecord(domainID, name, value) + err = d.deleteTXTRecord(domainID, fqdn, value) if err != nil { return fmt.Errorf("checkdomain: %w", err) } d.domainIDMu.Lock() - delete(d.domainIDMapping, name) + delete(d.domainIDMapping, fqdn) d.domainIDMu.Unlock() return nil diff --git a/providers/dns/dnsimple/dnsimple.go b/providers/dns/dnsimple/dnsimple.go index 87e348f9..58ff0aeb 100644 --- a/providers/dns/dnsimple/dnsimple.go +++ b/providers/dns/dnsimple/dnsimple.go @@ -93,7 +93,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneName, err := d.getHostedZone(domain) + zoneName, err := d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("dnsimple: %w", err) } @@ -116,7 +116,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) - records, err := d.findTxtRecords(domain, fqdn) + records, err := d.findTxtRecords(fqdn) if err != nil { return fmt.Errorf("dnsimple: %w", err) } @@ -144,7 +144,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { } func (d *DNSProvider) getHostedZone(domain string) (string, error) { - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", err } @@ -175,8 +175,8 @@ func (d *DNSProvider) getHostedZone(domain string) (string, error) { return hostedZone.Name, nil } -func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnsimple.ZoneRecord, error) { - zoneName, err := d.getHostedZone(domain) +func (d *DNSProvider) findTxtRecords(fqdn string) ([]dnsimple.ZoneRecord, error) { + zoneName, err := d.getHostedZone(fqdn) if err != nil { return nil, err } diff --git a/providers/dns/dnspod/dnspod.go b/providers/dns/dnspod/dnspod.go index 4c7ec7d5..02a0c92e 100644 --- a/providers/dns/dnspod/dnspod.go +++ b/providers/dns/dnspod/dnspod.go @@ -88,7 +88,8 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneID, zoneName, err := d.getHostedZone(domain) + + zoneID, zoneName, err := d.getHostedZone(fqdn) if err != nil { return err } @@ -106,12 +107,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) - records, err := d.findTxtRecords(domain, fqdn) + zoneID, zoneName, err := d.getHostedZone(fqdn) if err != nil { return err } - zoneID, _, err := d.getHostedZone(domain) + records, err := d.findTxtRecords(fqdn, zoneID, zoneName) if err != nil { return err } @@ -137,7 +138,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, string, error) { return "", "", fmt.Errorf("API call failed: %w", err) } - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", "", err } @@ -168,12 +169,7 @@ func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) *dnspod.Re } } -func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, error) { - zoneID, zoneName, err := d.getHostedZone(domain) - if err != nil { - return nil, err - } - +func (d *DNSProvider) findTxtRecords(fqdn, zoneID, zoneName string) ([]dnspod.Record, error) { recordName := extractRecordName(fqdn, zoneName) var records []dnspod.Record diff --git a/providers/dns/dynu/dynu.go b/providers/dns/dynu/dynu.go index 5dc5cc2d..33b42aab 100644 --- a/providers/dns/dynu/dynu.go +++ b/providers/dns/dynu/dynu.go @@ -99,6 +99,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. rootDomain, err := d.client.GetRootDomain(domain) if err != nil { return fmt.Errorf("dynu: could not find root domain for %s: %w", domain, err) @@ -138,6 +139,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. rootDomain, err := d.client.GetRootDomain(domain) if err != nil { return fmt.Errorf("dynu: could not find root domain for %s: %w", domain, err) diff --git a/providers/dns/edgedns/edgedns.go b/providers/dns/edgedns/edgedns.go index 401891ec..baeb01c4 100644 --- a/providers/dns/edgedns/edgedns.go +++ b/providers/dns/edgedns/edgedns.go @@ -109,7 +109,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zone, err := findZone(domain) + zone, err := findZone(fqdn) if err != nil { return fmt.Errorf("edgedns: %w", err) } @@ -161,7 +161,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zone, err := findZone(domain) + zone, err := findZone(fqdn) if err != nil { return fmt.Errorf("edgedns: %w", err) } @@ -215,7 +215,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func findZone(domain string) (string, error) { - zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + zone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", err } diff --git a/providers/dns/edgedns/edgedns_integration_test.go b/providers/dns/edgedns/edgedns_integration_test.go index ee9b563e..5ad0a5e3 100644 --- a/providers/dns/edgedns/edgedns_integration_test.go +++ b/providers/dns/edgedns/edgedns_integration_test.go @@ -66,7 +66,7 @@ func TestLiveTTL(t *testing.T) { }() fqdn := "_acme-challenge." + domain + "." - zone, err := findZone(domain) + zone, err := findZone(fqdn) require.NoError(t, err) resourceRecordSets, err := configdns.GetRecordList(zone, fqdn, "TXT") diff --git a/providers/dns/edgedns/edgedns_test.go b/providers/dns/edgedns/edgedns_test.go index 1819a151..3e855292 100644 --- a/providers/dns/edgedns/edgedns_test.go +++ b/providers/dns/edgedns/edgedns_test.go @@ -158,12 +158,12 @@ func TestDNSProvider_findZone(t *testing.T) { }{ { desc: "Extract root record name", - domain: "bar.com", + domain: "bar.com.", expected: "bar.com", }, { desc: "Extract sub record name", - domain: "foo.bar.com", + domain: "foo.bar.com.", expected: "bar.com", }, } diff --git a/providers/dns/exoscale/exoscale.go b/providers/dns/exoscale/exoscale.go index f4ec21e4..59a9495a 100644 --- a/providers/dns/exoscale/exoscale.go +++ b/providers/dns/exoscale/exoscale.go @@ -113,7 +113,8 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { ctx := context.Background() fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneName, recordName, err := d.findZoneAndRecordName(fqdn, domain) + + zoneName, recordName, err := d.findZoneAndRecordName(fqdn) if err != nil { return err } @@ -169,7 +170,8 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { ctx := context.Background() fqdn, _ := dns01.GetRecord(domain, keyAuth) - zoneName, recordName, err := d.findZoneAndRecordName(fqdn, domain) + + zoneName, recordName, err := d.findZoneAndRecordName(fqdn) if err != nil { return err } @@ -244,8 +246,8 @@ func (d *DNSProvider) findExistingRecordID(zoneID, recordName string) (string, e } // findZoneAndRecordName Extract DNS zone and DNS entry name. -func (d *DNSProvider) findZoneAndRecordName(fqdn, domain string) (string, string, error) { - zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) +func (d *DNSProvider) findZoneAndRecordName(fqdn string) (string, string, error) { + zone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return "", "", err } diff --git a/providers/dns/exoscale/exoscale_test.go b/providers/dns/exoscale/exoscale_test.go index 893bf4a1..2aad3fcf 100644 --- a/providers/dns/exoscale/exoscale_test.go +++ b/providers/dns/exoscale/exoscale_test.go @@ -140,22 +140,19 @@ func TestDNSProvider_FindZoneAndRecordName(t *testing.T) { testCases := []struct { desc string fqdn string - domain string expected expected }{ { - desc: "Extract root record name", - fqdn: "_acme-challenge.bar.com.", - domain: "bar.com", + desc: "Extract root record name", + fqdn: "_acme-challenge.bar.com.", expected: expected{ zone: "bar.com", recordName: "_acme-challenge", }, }, { - desc: "Extract sub record name", - fqdn: "_acme-challenge.foo.bar.com.", - domain: "foo.bar.com", + desc: "Extract sub record name", + fqdn: "_acme-challenge.foo.bar.com.", expected: expected{ zone: "bar.com", recordName: "_acme-challenge.foo", @@ -168,7 +165,7 @@ func TestDNSProvider_FindZoneAndRecordName(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - zone, recordName, err := provider.findZoneAndRecordName(test.fqdn, test.domain) + zone, recordName, err := provider.findZoneAndRecordName(test.fqdn) require.NoError(t, err) assert.Equal(t, test.expected.zone, zone) assert.Equal(t, test.expected.recordName, recordName) diff --git a/providers/dns/glesys/glesys.go b/providers/dns/glesys/glesys.go index 953b861f..81f8e7db 100644 --- a/providers/dns/glesys/glesys.go +++ b/providers/dns/glesys/glesys.go @@ -120,6 +120,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { defer d.inProgressMu.Unlock() // add TXT record into authZone + // TODO(ldez) replace domain by FQDN to follow CNAME. recordID, err := d.addTXTRecord(domain, dns01.UnFqdn(authZone), name, value, d.config.TTL) if err != nil { return err @@ -146,6 +147,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { delete(d.activeRecords, fqdn) // delete TXT record from authZone + // TODO(ldez) replace domain by FQDN to follow CNAME. return d.deleteTXTRecord(domain, recordID) } diff --git a/providers/dns/ibmcloud/ibmcloud.go b/providers/dns/ibmcloud/ibmcloud.go index bc64b8ec..1daccac7 100644 --- a/providers/dns/ibmcloud/ibmcloud.go +++ b/providers/dns/ibmcloud/ibmcloud.go @@ -108,6 +108,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. err := d.wrapper.AddTXTRecord(fqdn, domain, value, d.config.TTL) if err != nil { return fmt.Errorf("ibmcloud: %w", err) @@ -120,6 +121,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. err := d.wrapper.CleanupTXTRecord(fqdn, domain) if err != nil { return fmt.Errorf("ibmcloud: %w", err) diff --git a/providers/dns/iij/iij.go b/providers/dns/iij/iij.go index a32de614..377b5103 100644 --- a/providers/dns/iij/iij.go +++ b/providers/dns/iij/iij.go @@ -100,6 +100,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { _, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. err := d.deleteTxtRecord(domain, value) if err != nil { return fmt.Errorf("iij: %w", err) @@ -113,6 +114,7 @@ func (d *DNSProvider) addTxtRecord(domain, value string) error { return err } + // TODO(ldez) replace domain by FQDN to follow CNAME. owner, zone, err := splitDomain(domain, zones) if err != nil { return err diff --git a/providers/dns/iijdpf/iijdpf.go b/providers/dns/iijdpf/iijdpf.go index df700d6b..94424e7a 100644 --- a/providers/dns/iijdpf/iijdpf.go +++ b/providers/dns/iijdpf/iijdpf.go @@ -100,7 +100,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneID, err := dpfapiutils.GetZoneIdFromServiceCode(context.Background(), d.client, d.config.ServiceCode) + zoneID, err := dpfapiutils.GetZoneIdFromServiceCode(ctx, d.client, d.config.ServiceCode) if err != nil { return fmt.Errorf("iijdpf: failed to get zone id: %w", err) } @@ -124,7 +124,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneID, err := dpfapiutils.GetZoneIdFromServiceCode(context.Background(), d.client, d.config.ServiceCode) + zoneID, err := dpfapiutils.GetZoneIdFromServiceCode(ctx, d.client, d.config.ServiceCode) if err != nil { return fmt.Errorf("iijdpf: failed to get zone id: %w", err) } diff --git a/providers/dns/infomaniak/infomaniak.go b/providers/dns/infomaniak/infomaniak.go index 0d5e75ca..b68614b9 100644 --- a/providers/dns/infomaniak/infomaniak.go +++ b/providers/dns/infomaniak/infomaniak.go @@ -112,6 +112,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. ikDomain, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("infomaniak: could not get domain %q: %w", domain, err) diff --git a/providers/dns/ionos/ionos.go b/providers/dns/ionos/ionos.go index 6bf6c7a5..44fb2b0c 100644 --- a/providers/dns/ionos/ionos.go +++ b/providers/dns/ionos/ionos.go @@ -115,6 +115,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error { return fmt.Errorf("ionos: failed to get zones: %w", err) } + // TODO(ldez) replace domain by FQDN to follow CNAME. zone := findZone(zones, domain) if zone == nil { return errors.New("ionos: no matching zone found for domain") @@ -156,6 +157,7 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error { return fmt.Errorf("ionos: failed to get zones: %w", err) } + // TODO(ldez) replace domain by FQDN to follow CNAME. zone := findZone(zones, domain) if zone == nil { return errors.New("ionos: no matching zone found for domain") diff --git a/providers/dns/linode/linode.go b/providers/dns/linode/linode.go index 15209751..b18476a5 100644 --- a/providers/dns/linode/linode.go +++ b/providers/dns/linode/linode.go @@ -132,6 +132,7 @@ func (d *DNSProvider) Timeout() (time.Duration, time.Duration) { // Present creates a TXT record using the specified parameters. func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + zone, err := d.getHostedZoneInfo(fqdn) if err != nil { return err diff --git a/providers/dns/mydnsjp/mydnsjp.go b/providers/dns/mydnsjp/mydnsjp.go index 8fe42846..4dc3bdd3 100644 --- a/providers/dns/mydnsjp/mydnsjp.go +++ b/providers/dns/mydnsjp/mydnsjp.go @@ -87,6 +87,8 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { _, value := dns01.GetRecord(domain, keyAuth) + + // TODO(ldez) replace domain by FQDN to follow CNAME. err := d.doRequest(domain, value, "REGIST") if err != nil { return fmt.Errorf("mydnsjp: %w", err) @@ -97,6 +99,8 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { _, value := dns01.GetRecord(domain, keyAuth) + + // TODO(ldez) replace domain by FQDN to follow CNAME. err := d.doRequest(domain, value, "DELETE") if err != nil { return fmt.Errorf("mydnsjp: %w", err) diff --git a/providers/dns/namecheap/namecheap.go b/providers/dns/namecheap/namecheap.go index 4f185ec7..cd7b43d0 100644 --- a/providers/dns/namecheap/namecheap.go +++ b/providers/dns/namecheap/namecheap.go @@ -144,6 +144,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present installs a TXT record for the DNS challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { + // TODO(ldez) replace domain by FQDN to follow CNAME. ch, err := newChallenge(domain, keyAuth) if err != nil { return fmt.Errorf("namecheap: %w", err) @@ -179,6 +180,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes a TXT record used for a previous DNS challenge. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + // TODO(ldez) replace domain by FQDN to follow CNAME. ch, err := newChallenge(domain, keyAuth) if err != nil { return fmt.Errorf("namecheap: %w", err) diff --git a/providers/dns/namedotcom/namedotcom.go b/providers/dns/namedotcom/namedotcom.go index b7281f40..cee75df8 100644 --- a/providers/dns/namedotcom/namedotcom.go +++ b/providers/dns/namedotcom/namedotcom.go @@ -108,11 +108,13 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. domainDetails, err := d.client.GetDomain(&namecom.GetDomainRequest{DomainName: domain}) if err != nil { return fmt.Errorf("namedotcom API call failed: %w", err) } + // TODO(ldez) replace domain by FQDN to follow CNAME. request := &namecom.Record{ DomainName: domain, Host: extractRecordName(fqdn, domainDetails.DomainName), @@ -133,6 +135,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. records, err := d.getRecords(domain) if err != nil { return fmt.Errorf("namedotcom: %w", err) @@ -140,6 +143,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { for _, rec := range records { if rec.Fqdn == fqdn && rec.Type == "TXT" { + // TODO(ldez) replace domain by FQDN to follow CNAME. request := &namecom.DeleteRecordRequest{ DomainName: domain, ID: rec.ID, diff --git a/providers/dns/namesilo/namesilo.go b/providers/dns/namesilo/namesilo.go index 44f86cf0..8cb9cd4b 100644 --- a/providers/dns/namesilo/namesilo.go +++ b/providers/dns/namesilo/namesilo.go @@ -89,7 +89,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zoneName, err := getZoneNameByDomain(domain) + zoneName, err := getZoneNameByDomain(fqdn) if err != nil { return fmt.Errorf("namesilo: %w", err) } @@ -111,7 +111,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) - zoneName, err := getZoneNameByDomain(domain) + zoneName, err := getZoneNameByDomain(fqdn) if err != nil { return fmt.Errorf("namesilo: %w", err) } @@ -141,7 +141,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { } func getZoneNameByDomain(domain string) (string, error) { - zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + zone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", fmt.Errorf("failed to find zone for domain: %s, %w", domain, err) } diff --git a/providers/dns/nearlyfreespeech/nearlyfreespeech.go b/providers/dns/nearlyfreespeech/nearlyfreespeech.go index b03ba0f9..62fa1842 100644 --- a/providers/dns/nearlyfreespeech/nearlyfreespeech.go +++ b/providers/dns/nearlyfreespeech/nearlyfreespeech.go @@ -110,9 +110,9 @@ func (d *DNSProvider) Sequential() time.Duration { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { - return fmt.Errorf("nearlyfreespeech: could not determine zone for domain %q: %w", domain, err) + return fmt.Errorf("nearlyfreespeech: could not determine zone for domain %q: %w", fqdn, err) } record := internal.Record{ @@ -134,9 +134,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { - return fmt.Errorf("nearlyfreespeech: could not determine zone for domain %q: %w", domain, err) + return fmt.Errorf("nearlyfreespeech: could not determine zone for domain %q: %w", fqdn, err) } record := internal.Record{ diff --git a/providers/dns/netcup/netcup.go b/providers/dns/netcup/netcup.go index bafb0153..ba8220a0 100644 --- a/providers/dns/netcup/netcup.go +++ b/providers/dns/netcup/netcup.go @@ -91,8 +91,8 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { } // Present creates a TXT record to fulfill the dns-01 challenge. -func (d *DNSProvider) Present(domainName, token, keyAuth string) error { - fqdn, value := dns01.GetRecord(domainName, keyAuth) +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value := dns01.GetRecord(domain, keyAuth) zone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { @@ -138,8 +138,8 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error { } // CleanUp removes the TXT record matching the specified parameters. -func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error { - fqdn, value := dns01.GetRecord(domainName, keyAuth) +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, value := dns01.GetRecord(domain, keyAuth) zone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { diff --git a/providers/dns/nicmanager/nicmanager.go b/providers/dns/nicmanager/nicmanager.go index c485b6b5..9dec4852 100644 --- a/providers/dns/nicmanager/nicmanager.go +++ b/providers/dns/nicmanager/nicmanager.go @@ -137,9 +137,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - rootDomain, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + rootDomain, err := dns01.FindZoneByFqdn(fqdn) if err != nil { - return fmt.Errorf("nicmanager: could not determine zone for domain %q: %w", domain, err) + return fmt.Errorf("nicmanager: could not determine zone for domain %q: %w", fqdn, err) } zone, err := d.client.GetZone(dns01.UnFqdn(rootDomain)) @@ -168,9 +168,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - rootDomain, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + rootDomain, err := dns01.FindZoneByFqdn(fqdn) if err != nil { - return fmt.Errorf("nicmanager: could not determine zone for domain %q: %w", domain, err) + return fmt.Errorf("nicmanager: could not determine zone for domain %q: %w", fqdn, err) } zone, err := d.client.GetZone(dns01.UnFqdn(rootDomain)) diff --git a/providers/dns/sakuracloud/client.go b/providers/dns/sakuracloud/client.go index c6df7f53..b45221f1 100644 --- a/providers/dns/sakuracloud/client.go +++ b/providers/dns/sakuracloud/client.go @@ -15,11 +15,11 @@ import ( // see: https://github.com/go-acme/lego/pull/850 var mu sync.Mutex -func (d *DNSProvider) addTXTRecord(fqdn, domain, value string, ttl int) error { +func (d *DNSProvider) addTXTRecord(fqdn, value string, ttl int) error { mu.Lock() defer mu.Unlock() - zone, err := d.getHostedZone(domain) + zone, err := d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("%w", err) } @@ -43,11 +43,11 @@ func (d *DNSProvider) addTXTRecord(fqdn, domain, value string, ttl int) error { return nil } -func (d *DNSProvider) cleanupTXTRecord(fqdn, domain, value string) error { +func (d *DNSProvider) cleanupTXTRecord(fqdn, value string) error { mu.Lock() defer mu.Unlock() - zone, err := d.getHostedZone(domain) + zone, err := d.getHostedZone(fqdn) if err != nil { return err } @@ -74,7 +74,7 @@ func (d *DNSProvider) cleanupTXTRecord(fqdn, domain, value string) error { } func (d *DNSProvider) getHostedZone(domain string) (*iaas.DNS, error) { - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return nil, err } diff --git a/providers/dns/sakuracloud/client_test.go b/providers/dns/sakuracloud/client_test.go index 831024ea..e9c7bc64 100644 --- a/providers/dns/sakuracloud/client_test.go +++ b/providers/dns/sakuracloud/client_test.go @@ -65,10 +65,10 @@ func TestDNSProvider_addAndCleanupRecords(t *testing.T) { require.NoError(t, err) t.Run("addTXTRecord", func(t *testing.T) { - err = p.addTXTRecord("test.example.com", "example.com", "dummyValue", 10) + err = p.addTXTRecord("test.example.com.", "dummyValue", 10) require.NoError(t, err) - updZone, e := p.getHostedZone("example.com") + updZone, e := p.getHostedZone("test.example.com.") require.NoError(t, e) require.NotNil(t, updZone) @@ -76,10 +76,10 @@ func TestDNSProvider_addAndCleanupRecords(t *testing.T) { }) t.Run("cleanupTXTRecord", func(t *testing.T) { - err = p.cleanupTXTRecord("test.example.com", "example.com", "dummyValue") + err = p.cleanupTXTRecord("test.example.com.", "dummyValue") require.NoError(t, err) - updZone, e := p.getHostedZone("example.com") + updZone, e := p.getHostedZone("test.example.com.") require.NoError(t, e) require.NotNil(t, updZone) @@ -111,7 +111,7 @@ func TestDNSProvider_concurrentAddAndCleanupRecords(t *testing.T) { for i, p := range providers { go func(j int, client *DNSProvider) { - err := client.addTXTRecord(fmt.Sprintf("test%d.example.com", j), "example.com", "dummyValue", 10) + err := client.addTXTRecord(fmt.Sprintf("test%d.example.com.", j), "dummyValue", 10) require.NoError(t, err) wg.Done() }(i, p) @@ -119,7 +119,7 @@ func TestDNSProvider_concurrentAddAndCleanupRecords(t *testing.T) { wg.Wait() - updZone, err := providers[0].getHostedZone("example.com") + updZone, err := providers[0].getHostedZone("example.com.") require.NoError(t, err) require.NotNil(t, updZone) @@ -131,7 +131,7 @@ func TestDNSProvider_concurrentAddAndCleanupRecords(t *testing.T) { for i, p := range providers { go func(i int, client *DNSProvider) { - err := client.cleanupTXTRecord(fmt.Sprintf("test%d.example.com", i), "example.com", "dummyValue") + err := client.cleanupTXTRecord(fmt.Sprintf("test%d.example.com.", i), "dummyValue") require.NoError(t, err) wg.Done() }(i, p) @@ -139,7 +139,7 @@ func TestDNSProvider_concurrentAddAndCleanupRecords(t *testing.T) { wg.Wait() - updZone, err := providers[0].getHostedZone("example.com") + updZone, err := providers[0].getHostedZone("example.com.") require.NoError(t, err) require.NotNil(t, updZone) diff --git a/providers/dns/sakuracloud/sakuracloud.go b/providers/dns/sakuracloud/sakuracloud.go index 2cb523ce..5b2f7691 100644 --- a/providers/dns/sakuracloud/sakuracloud.go +++ b/providers/dns/sakuracloud/sakuracloud.go @@ -109,7 +109,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - err := d.addTXTRecord(fqdn, domain, value, d.config.TTL) + err := d.addTXTRecord(fqdn, value, d.config.TTL) if err != nil { return fmt.Errorf("sakuracloud: %w", err) } @@ -121,7 +121,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - err := d.cleanupTXTRecord(fqdn, domain, value) + err := d.cleanupTXTRecord(fqdn, value) if err != nil { return fmt.Errorf("sakuracloud: %w", err) } diff --git a/providers/dns/scaleway/scaleway.go b/providers/dns/scaleway/scaleway.go index 8c45ec90..fb31bbae 100644 --- a/providers/dns/scaleway/scaleway.go +++ b/providers/dns/scaleway/scaleway.go @@ -121,6 +121,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Comment: scw.StringPtr("used by lego"), }} + // TODO(ldez) replace domain by FQDN to follow CNAME. req := &scwdomain.UpdateDNSZoneRecordsRequest{ DNSZone: domain, Changes: []*scwdomain.RecordChange{{ @@ -147,6 +148,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { Data: scw.StringPtr(fmt.Sprintf(`%q`, value)), } + // TODO(ldez) replace domain by FQDN to follow CNAME. req := &scwdomain.UpdateDNSZoneRecordsRequest{ DNSZone: domain, Changes: []*scwdomain.RecordChange{{ diff --git a/providers/dns/selectel/selectel.go b/providers/dns/selectel/selectel.go index 01b2bb52..f453ca77 100644 --- a/providers/dns/selectel/selectel.go +++ b/providers/dns/selectel/selectel.go @@ -103,6 +103,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. domainObj, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("selectel: %w", err) @@ -127,6 +128,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) recordName := dns01.UnFqdn(fqdn) + // TODO(ldez) replace domain by FQDN to follow CNAME. domainObj, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("selectel: %w", err) diff --git a/providers/dns/servercow/servercow.go b/providers/dns/servercow/servercow.go index c62f4258..664f07ae 100644 --- a/providers/dns/servercow/servercow.go +++ b/providers/dns/servercow/servercow.go @@ -99,7 +99,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := getAuthZone(domain) + authZone, err := getAuthZone(fqdn) if err != nil { return fmt.Errorf("servercow: %w", err) } @@ -152,7 +152,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := getAuthZone(domain) + authZone, err := getAuthZone(fqdn) if err != nil { return fmt.Errorf("servercow: %w", err) } @@ -203,7 +203,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func getAuthZone(domain string) (string, error) { - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", fmt.Errorf("could not find zone for domain %q: %w", domain, err) } diff --git a/providers/dns/sonic/sonic.go b/providers/dns/sonic/sonic.go index 3883cb9f..1c6da467 100644 --- a/providers/dns/sonic/sonic.go +++ b/providers/dns/sonic/sonic.go @@ -91,8 +91,8 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { } // Present creates a TXT record using the specified parameters. -func (d *DNSProvider) Present(domainName, token, keyAuth string) error { - fqdn, value := dns01.GetRecord(domainName, keyAuth) +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value := dns01.GetRecord(domain, keyAuth) err := d.client.SetRecord(dns01.UnFqdn(fqdn), value, d.config.TTL) if err != nil { @@ -103,8 +103,8 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error { } // CleanUp removes the TXT records matching the specified parameters. -func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error { - fqdn, _ := dns01.GetRecord(domainName, keyAuth) +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, _ := dns01.GetRecord(domain, keyAuth) err := d.client.SetRecord(dns01.UnFqdn(fqdn), "_", d.config.TTL) if err != nil { diff --git a/providers/dns/stackpath/client.go b/providers/dns/stackpath/client.go index e1290f84..9050a17f 100644 --- a/providers/dns/stackpath/client.go +++ b/providers/dns/stackpath/client.go @@ -50,8 +50,7 @@ func (e *ErrorResponse) Error() string { // https://developer.stackpath.com/en/api/dns/#operation/GetZones func (d *DNSProvider) getZones(domain string) (*Zone, error) { - domain = dns01.UnFqdn(domain) - tld, err := publicsuffix.EffectiveTLDPlusOne(domain) + tld, err := publicsuffix.EffectiveTLDPlusOne(dns01.UnFqdn(domain)) if err != nil { return nil, err } diff --git a/providers/dns/stackpath/stackpath.go b/providers/dns/stackpath/stackpath.go index 19efc1ae..14abd3c2 100644 --- a/providers/dns/stackpath/stackpath.go +++ b/providers/dns/stackpath/stackpath.go @@ -113,13 +113,13 @@ func getOathClient(config *Config) *http.Client { // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { - zone, err := d.getZones(domain) + fqdn, value := dns01.GetRecord(domain, keyAuth) + + zone, err := d.getZones(fqdn) if err != nil { return fmt.Errorf("stackpath: %w", err) } - fqdn, value := dns01.GetRecord(domain, keyAuth) - record := Record{ Name: extractRecordName(fqdn, zone.Domain), Type: "TXT", @@ -132,12 +132,13 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - zone, err := d.getZones(domain) + fqdn, _ := dns01.GetRecord(domain, keyAuth) + + zone, err := d.getZones(fqdn) if err != nil { return fmt.Errorf("stackpath: %w", err) } - fqdn, _ := dns01.GetRecord(domain, keyAuth) recordName := extractRecordName(fqdn, zone.Domain) records, err := d.getZoneRecords(recordName, zone) diff --git a/providers/dns/tencentcloud/client.go b/providers/dns/tencentcloud/client.go index 83dc8086..22315c36 100644 --- a/providers/dns/tencentcloud/client.go +++ b/providers/dns/tencentcloud/client.go @@ -32,7 +32,7 @@ func (d *DNSProvider) getHostedZone(domain string) (*dnspod.DomainListItem, erro request.Offset = common.Int64Ptr(int64(len(domains))) } - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return nil, err } diff --git a/providers/dns/tencentcloud/tencentcloud.go b/providers/dns/tencentcloud/tencentcloud.go index 86f64939..8cd7ae82 100644 --- a/providers/dns/tencentcloud/tencentcloud.go +++ b/providers/dns/tencentcloud/tencentcloud.go @@ -114,7 +114,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zone, err := d.getHostedZone(domain) + zone, err := d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("tencentcloud: failed to get hosted zone: %w", err) } @@ -145,7 +145,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) - zone, err := d.getHostedZone(domain) + zone, err := d.getHostedZone(fqdn) if err != nil { return fmt.Errorf("tencentcloud: failed to get hosted zone: %w", err) } diff --git a/providers/dns/vercel/vercel.go b/providers/dns/vercel/vercel.go index 9f0bfb83..b30ddc97 100644 --- a/providers/dns/vercel/vercel.go +++ b/providers/dns/vercel/vercel.go @@ -105,7 +105,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return fmt.Errorf("vercel: could not determine zone for domain %q: %w", domain, err) } diff --git a/providers/dns/versio/versio.go b/providers/dns/versio/versio.go index 33ca43ce..9c11db84 100644 --- a/providers/dns/versio/versio.go +++ b/providers/dns/versio/versio.go @@ -139,6 +139,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return fmt.Errorf("versio: %w", err) diff --git a/providers/dns/vscale/vscale.go b/providers/dns/vscale/vscale.go index 95809b9d..c3aa9e7c 100644 --- a/providers/dns/vscale/vscale.go +++ b/providers/dns/vscale/vscale.go @@ -103,6 +103,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. domainObj, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("vscale: %w", err) @@ -127,6 +128,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) recordName := dns01.UnFqdn(fqdn) + // TODO(ldez) replace domain by FQDN to follow CNAME. domainObj, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("vscale: %w", err) diff --git a/providers/dns/vultr/vultr.go b/providers/dns/vultr/vultr.go index d658be49..c29f8428 100644 --- a/providers/dns/vultr/vultr.go +++ b/providers/dns/vultr/vultr.go @@ -99,6 +99,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. zoneDomain, err := d.getHostedZone(ctx, domain) if err != nil { return fmt.Errorf("vultr: %w", err) @@ -127,6 +128,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) + // TODO(ldez) replace domain by FQDN to follow CNAME. zoneDomain, records, err := d.findTxtRecords(ctx, domain, fqdn) if err != nil { return fmt.Errorf("vultr: %w", err) diff --git a/providers/dns/zoneee/zoneee.go b/providers/dns/zoneee/zoneee.go index a8d29f41..fbb07593 100644 --- a/providers/dns/zoneee/zoneee.go +++ b/providers/dns/zoneee/zoneee.go @@ -112,7 +112,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Destination: value, } - authZone, err := getHostedZone(domain) + authZone, err := getHostedZone(fqdn) if err != nil { return fmt.Errorf("zoneee: %w", err) } @@ -126,9 +126,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record previously created. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - _, value := dns01.GetRecord(domain, keyAuth) + fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := getHostedZone(domain) + authZone, err := getHostedZone(fqdn) if err != nil { return fmt.Errorf("zoneee: %w", err) } @@ -157,11 +157,10 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func getHostedZone(domain string) (string, error) { - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + authZone, err := dns01.FindZoneByFqdn(domain) if err != nil { return "", err } - zoneName := dns01.UnFqdn(authZone) - return zoneName, nil + return dns01.UnFqdn(authZone), nil }