diff --git a/providers/dns/pdns/client.go b/providers/dns/pdns/client.go index 2f685640..1467da63 100644 --- a/providers/dns/pdns/client.go +++ b/providers/dns/pdns/client.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/go-acme/lego/v4/challenge/dns01" + "github.com/miekg/dns" ) type Record struct { @@ -60,37 +61,19 @@ type apiVersion struct { } func (d *DNSProvider) getHostedZone(fqdn string) (*hostedZone, error) { - var zone hostedZone authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return nil, err } - u := "/servers/localhost/zones" - result, err := d.sendRequest(http.MethodGet, u, nil) - if err != nil { - return nil, err - } - - var zones []hostedZone - err = json.Unmarshal(result, &zones) - if err != nil { - return nil, err - } - - u = "" - for _, zone := range zones { - if dns01.UnFqdn(zone.Name) == dns01.UnFqdn(authZone) { - u = zone.URL - break - } - } - - result, err = d.sendRequest(http.MethodGet, u, nil) + p := path.Join("/servers/localhost/zones/", dns.Fqdn(authZone)) + + result, err := d.sendRequest(http.MethodGet, p, nil) if err != nil { return nil, err } + var zone hostedZone err = json.Unmarshal(result, &zone) if err != nil { return nil, err