forked from TrueCloudLab/lego
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:
parent
0ce6ba36b9
commit
b668bde5e4
2 changed files with 18 additions and 2 deletions
|
@ -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) {
|
func (d *DNSProvider) getAPIVersion() (int, error) {
|
||||||
|
|
|
@ -121,6 +121,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
TTL: d.config.TTL,
|
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 := rrSets{
|
||||||
RRSets: []rrSet{
|
RRSets: []rrSet{
|
||||||
{
|
{
|
||||||
|
@ -129,7 +142,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
Type: "TXT",
|
Type: "TXT",
|
||||||
Kind: "Master",
|
Kind: "Master",
|
||||||
TTL: d.config.TTL,
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("pdns: %v", err)
|
return fmt.Errorf("pdns: %v", err)
|
||||||
}
|
}
|
||||||
|
if set == nil {
|
||||||
|
return fmt.Errorf("pdns: no existing record found for %s", fqdn)
|
||||||
|
}
|
||||||
|
|
||||||
rrsets := rrSets{
|
rrsets := rrSets{
|
||||||
RRSets: []rrSet{
|
RRSets: []rrSet{
|
||||||
|
|
Loading…
Reference in a new issue