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.
|
||||
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 {
|
||||
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.
|
||||
func (d *DNSProvider) CleanUp(domain, _, _ string) error {
|
||||
err := d.client.UpdateTxtRecord(context.Background(), domain, ".")
|
||||
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||
|
||||
err := d.client.UpdateTxtRecord(context.Background(), dns01.UnFqdn(fqdn), ".")
|
||||
if err != nil {
|
||||
return fmt.Errorf("hurricane: %w", err)
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ func NewClient(credentials map[string]string) *Client {
|
|||
}
|
||||
|
||||
// UpdateTxtRecord updates a TXT record.
|
||||
func (c *Client) UpdateTxtRecord(ctx context.Context, domain string, txt string) error {
|
||||
hostname := fmt.Sprintf("_acme-challenge.%s", domain)
|
||||
func (c *Client) UpdateTxtRecord(ctx context.Context, hostname string, txt string) error {
|
||||
domain := strings.TrimPrefix(hostname, "_acme-challenge.")
|
||||
|
||||
c.credMu.Lock()
|
||||
token, ok := c.credentials[domain]
|
||||
|
|
|
@ -75,7 +75,7 @@ func TestClient_UpdateTxtRecord(t *testing.T) {
|
|||
client := NewClient(map[string]string{"example.com": "secret"})
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue