pdns: fix wildcard with SANs (#837)

The current implementation of the DNS challenge does not allow
to set multiple TXT records at once.

As PowerDNS has the concept of record sets, and so all records
for the same type and name must set during one call, we would override
existing records.

To avoid this, we merge the new TXT record with existing ones
This commit is contained in:
tbe 2019-03-21 15:46:21 +01:00 committed by Ludovic Fernandez
parent 0ce6ba36b9
commit b668bde5e4
2 changed files with 18 additions and 2 deletions

View file

@ -127,7 +127,7 @@ func (d *DNSProvider) findTxtRecord(fqdn string) (*rrSet, error) {
}
}
return nil, fmt.Errorf("no existing record found for %s", fqdn)
return nil, nil
}
func (d *DNSProvider) getAPIVersion() (int, error) {

View file

@ -121,6 +121,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
TTL: d.config.TTL,
}
// Look for existing records.
existingRrSet, err := d.findTxtRecord(fqdn)
if err != nil {
return fmt.Errorf("pdns: %v", err)
}
// merge the existing and new records
var records []Record
if existingRrSet != nil {
records = existingRrSet.Records
}
records = append(records, rec)
rrsets := rrSets{
RRSets: []rrSet{
{
@ -129,7 +142,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
Type: "TXT",
Kind: "Master",
TTL: d.config.TTL,
Records: []Record{rec},
Records: records,
},
},
}
@ -159,6 +172,9 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
if err != nil {
return fmt.Errorf("pdns: %v", err)
}
if set == nil {
return fmt.Errorf("pdns: no existing record found for %s", fqdn)
}
rrsets := rrSets{
RRSets: []rrSet{