Skip to content

Commit

Permalink
NS1: use the authoritative zone and not the domain name (go-acme#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
scoursen authored and ldez committed Jul 14, 2018
1 parent 255296e commit 771679f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion providers/dns/ns1/ns1.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ns1
import (
"fmt"
"net/http"
"strings"
"time"

"github.com/xenolf/lego/acme"
Expand Down Expand Up @@ -75,14 +76,32 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
}

func (d *DNSProvider) getHostedZone(domain string) (*dns.Zone, error) {
zone, _, err := d.client.Zones.Get(domain)
authZone, err := getAuthZone(domain)
if err != nil {
return nil, err
}

zone, _, err := d.client.Zones.Get(authZone)
if err != nil {
return nil, err
}

return zone, nil
}

func getAuthZone(fqdn string) (string, error) {
authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers)
if err != nil {
return "", err
}

if strings.HasSuffix(authZone, ".") {
authZone = authZone[:len(authZone)-len(".")]
}

return authZone, err
}

func (d *DNSProvider) newTxtRecord(zone *dns.Zone, fqdn, value string, ttl int) *dns.Record {
name := acme.UnFqdn(fqdn)

Expand Down

0 comments on commit 771679f

Please sign in to comment.