forked from TrueCloudLab/lego
Fix GoogleCloud DNS challenge to allow subdomains
Fixes #257 Previously the google cloud provider assumed the domain being provided was also the authoritative zone. This fix uses an acme function to recursively lookup the authoritative zone for a provided domain.
This commit is contained in:
parent
aa216e0399
commit
de8a56bde8
1 changed files with 9 additions and 9 deletions
|
@ -5,7 +5,6 @@ package googlecloud
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xenolf/lego/acme"
|
"github.com/xenolf/lego/acme"
|
||||||
|
@ -121,23 +120,24 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
|
|
||||||
// getHostedZone returns the managed-zone
|
// getHostedZone returns the managed-zone
|
||||||
func (c *DNSProvider) getHostedZone(domain string) (string, error) {
|
func (c *DNSProvider) getHostedZone(domain string) (string, error) {
|
||||||
dnsName := domain + "."
|
authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
zones, err := c.client.ManagedZones.
|
zones, err := c.client.ManagedZones.
|
||||||
List(c.project).
|
List(c.project).
|
||||||
DnsName(dnsName).
|
DnsName(authZone).
|
||||||
Do()
|
Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("GoogleCloud API call failed: %v", err)
|
return "", fmt.Errorf("GoogleCloud API call failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, z := range zones.ManagedZones {
|
if len(zones.ManagedZones) == 0 {
|
||||||
if strings.HasSuffix(dnsName, z.DnsName) {
|
return "", fmt.Errorf("No matching GoogleCloud domain found for domain %s", authZone)
|
||||||
return z.Name, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", fmt.Errorf("No matching GoogleCloud domain found for domain %s", domain)
|
return zones.ManagedZones[0].Name, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DNSProvider) findTxtRecords(zone, fqdn string) ([]*dns.ResourceRecordSet, error) {
|
func (c *DNSProvider) findTxtRecords(zone, fqdn string) ([]*dns.ResourceRecordSet, error) {
|
||||||
|
|
Loading…
Reference in a new issue