DNSimpleProvider: Fix bug with subdomains
When requesting a certificate for a subdomain, the DNS record was attached to the domain instead. E.g. Requested: ww1.example.com Created: _acme-challenge.example.com instead of _acme-challenge.ww1.example.com
This commit is contained in:
parent
adc8afbb89
commit
753f9ca798
1 changed files with 10 additions and 10 deletions
|
@ -35,12 +35,12 @@ func NewDNSProviderDNSimple(dnsimpleEmail, dnsimpleApiKey string) (*DNSProviderD
|
||||||
func (c *DNSProviderDNSimple) Present(domain, token, keyAuth string) error {
|
func (c *DNSProviderDNSimple) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value, ttl := DNS01Record(domain, keyAuth)
|
fqdn, value, ttl := DNS01Record(domain, keyAuth)
|
||||||
|
|
||||||
zoneID, err := c.getHostedZoneID(domain)
|
zoneID, zoneName, err := c.getHostedZone(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
recordAttributes := c.newTxtRecord(domain, fqdn, value, ttl)
|
recordAttributes := c.newTxtRecord(zoneName, fqdn, value, ttl)
|
||||||
_, _, err = c.client.Domains.CreateRecord(zoneID, *recordAttributes)
|
_, _, err = c.client.Domains.CreateRecord(zoneID, *recordAttributes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("DNSimple API call failed: %v", err)
|
return fmt.Errorf("DNSimple API call failed: %v", err)
|
||||||
|
@ -67,10 +67,10 @@ func (c *DNSProviderDNSimple) CleanUp(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DNSProviderDNSimple) getHostedZoneID(domain string) (string, error) {
|
func (c *DNSProviderDNSimple) getHostedZone(domain string) (string, string, error) {
|
||||||
domains, _, err := c.client.Domains.List()
|
domains, _, err := c.client.Domains.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("DNSimple API call failed: %v", err)
|
return "", "", fmt.Errorf("DNSimple API call failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hostedDomain dnsimple.Domain
|
var hostedDomain dnsimple.Domain
|
||||||
|
@ -82,14 +82,14 @@ func (c *DNSProviderDNSimple) getHostedZoneID(domain string) (string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if hostedDomain.Id == 0 {
|
if hostedDomain.Id == 0 {
|
||||||
return "", fmt.Errorf("No matching DNSimple domain found for domain %s", domain)
|
return "", "", fmt.Errorf("No matching DNSimple domain found for domain %s", domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%v", hostedDomain.Id), nil
|
return fmt.Sprintf("%v", hostedDomain.Id), hostedDomain.Name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DNSProviderDNSimple) findTxtRecords(domain, fqdn string) ([]*dnsimple.Record, error) {
|
func (c *DNSProviderDNSimple) findTxtRecords(domain, fqdn string) ([]*dnsimple.Record, error) {
|
||||||
zoneID, err := c.getHostedZoneID(domain)
|
zoneID, zoneName, err := c.getHostedZone(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (c *DNSProviderDNSimple) findTxtRecords(domain, fqdn string) ([]*dnsimple.R
|
||||||
return records, fmt.Errorf("DNSimple API call has failed: %v", err)
|
return records, fmt.Errorf("DNSimple API call has failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName := c.extractRecordName(fqdn, domain)
|
recordName := c.extractRecordName(fqdn, zoneName)
|
||||||
for _, record := range result {
|
for _, record := range result {
|
||||||
if record.Name == recordName {
|
if record.Name == recordName {
|
||||||
records = append(records, &record)
|
records = append(records, &record)
|
||||||
|
@ -110,8 +110,8 @@ func (c *DNSProviderDNSimple) findTxtRecords(domain, fqdn string) ([]*dnsimple.R
|
||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DNSProviderDNSimple) newTxtRecord(domain, fqdn, value string, ttl int) *dnsimple.Record {
|
func (c *DNSProviderDNSimple) newTxtRecord(zone, fqdn, value string, ttl int) *dnsimple.Record {
|
||||||
name := c.extractRecordName(fqdn, domain)
|
name := c.extractRecordName(fqdn, zone)
|
||||||
|
|
||||||
return &dnsimple.Record{
|
return &dnsimple.Record{
|
||||||
Type: "TXT",
|
Type: "TXT",
|
||||||
|
|
Loading…
Reference in a new issue