forked from TrueCloudLab/lego
Merge pull request #262 from doublerr/google_multi_subdomains
Fix GoogleCloud DNS challenge to allow subdomains
This commit is contained in:
commit
eb7c5e6bb6
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