kaechele / certbot-dns-pdns

Certbot DNS Authenticator for PowerDNS
Other
4 stars 1 forks source link

fix: early exit when domain is not equal to the powerdns zone #42

Closed matdal5423 closed 3 months ago

matdal5423 commented 4 months ago

When you try to create a certificate for a specific host that is not the domain it self you get this error: Error determining zone identifier for foo.bar.baz.example.com: '404 Client Error: Not Found for url: http://dns.example.com/api/v1/servers/localhost/zones/foo.bar.baz.example.com.'. (Is your server ID correct?)

This is because the function __resolvedomain defined in class LexiconDNSAuthenticator return the 404 error during the cycle when is checking what are the correct dns zone where to add the TXT challenge record. This seam a normal behaviour of powerdns API.

This fix check if we are at the last iteration of the cycle by evaluate the number of element after split the domain_namy by '.' in this way if we are at the end of the cycle in the list there will be only 1 element, the TLD.

matdal5423 commented 4 months ago

From Powerdns documentation: https://doc.powerdns.com/authoritative/http-api/zone.html

404 Not Found – Requested item was not found Returns: Error object

kaechele commented 4 months ago

Thanks for reporting this. I was able to verify the bug and also your fix.

A few things:

Let me know if you need any help or further explanation on this, I'm happy to help. If you don't feel like doing that I can also do it on my end, if you prefer.

matdal5423 commented 4 months ago

Hi, I hope now is al correct. I learn something new and 42 is a lucky number!

Thank you!

matdal5423 commented 4 months ago

Hi @kaechele, any update?

kaechele commented 3 months ago

Sorry about the delay. Thanks for fixing this! Merging :)