forked from TrueCloudLab/lego
hurricane: fix CNAME support (#1734)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
parent
5e37ee3822
commit
7cfa075581
3 changed files with 9 additions and 7 deletions
|
@ -86,9 +86,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
|
|
||||||
// Present updates a TXT record to fulfill the dns-01 challenge.
|
// Present updates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||||
_, txtRecord := dns01.GetRecord(domain, keyAuth)
|
fqdn, txtRecord := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
err := d.client.UpdateTxtRecord(context.Background(), domain, txtRecord)
|
err := d.client.UpdateTxtRecord(context.Background(), dns01.UnFqdn(fqdn), txtRecord)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("hurricane: %w", err)
|
return fmt.Errorf("hurricane: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,10 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp updates the TXT record matching the specified parameters.
|
// CleanUp updates the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, _, _ string) error {
|
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
||||||
err := d.client.UpdateTxtRecord(context.Background(), domain, ".")
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
err := d.client.UpdateTxtRecord(context.Background(), dns01.UnFqdn(fqdn), ".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("hurricane: %w", err)
|
return fmt.Errorf("hurricane: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ func NewClient(credentials map[string]string) *Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateTxtRecord updates a TXT record.
|
// UpdateTxtRecord updates a TXT record.
|
||||||
func (c *Client) UpdateTxtRecord(ctx context.Context, domain string, txt string) error {
|
func (c *Client) UpdateTxtRecord(ctx context.Context, hostname string, txt string) error {
|
||||||
hostname := fmt.Sprintf("_acme-challenge.%s", domain)
|
domain := strings.TrimPrefix(hostname, "_acme-challenge.")
|
||||||
|
|
||||||
c.credMu.Lock()
|
c.credMu.Lock()
|
||||||
token, ok := c.credentials[domain]
|
token, ok := c.credentials[domain]
|
||||||
|
|
|
@ -75,7 +75,7 @@ func TestClient_UpdateTxtRecord(t *testing.T) {
|
||||||
client := NewClient(map[string]string{"example.com": "secret"})
|
client := NewClient(map[string]string{"example.com": "secret"})
|
||||||
client.baseURL = server.URL
|
client.baseURL = server.URL
|
||||||
|
|
||||||
err := client.UpdateTxtRecord(context.Background(), "example.com", "foo")
|
err := client.UpdateTxtRecord(context.Background(), "_acme-challenge.example.com", "foo")
|
||||||
test.expected(t, err)
|
test.expected(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue