From a281298db64c36651c8a56aacb0c8717d62cf33f Mon Sep 17 00:00:00 2001 From: Thomas M Steenholdt Date: Tue, 12 Oct 2021 11:23:35 -0200 Subject: [PATCH] Add support for the PowerDNS-Admin API --- README.md | 4 ++++ certbot_dns_powerdns/dns_powerdns.py | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 739e3c2..6deb5ef 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ certbot-dns-powerdns PowerDNS DNS Authenticator plugin for [Certbot](https://certbot.eff.org/). +Compatibility: +* PowerDNS Authoritative Server API +* PowerDNS-Admin API + This plugin is built from the ground up and follows the development style and life-cycle of other `certbot-dns-*` plugins found in the [Official Certbot Repository](https://github.com/certbot/certbot). diff --git a/certbot_dns_powerdns/dns_powerdns.py b/certbot_dns_powerdns/dns_powerdns.py index 55fe2ee..541bdd7 100644 --- a/certbot_dns_powerdns/dns_powerdns.py +++ b/certbot_dns_powerdns/dns_powerdns.py @@ -84,11 +84,9 @@ def __init__(self, api_url, api_key, ttl): self.provider = powerdns.Provider(config) def _handle_http_error(self, e, domain_name): - if domain_name in str(e) and ( - # 4.0 and 4.1 compatibility - str(e).startswith('422 Client Error: Unprocessable Entity for url:') or - # 4.2 - str(e).startswith('404 Client Error: Not Found for url:') - ): - return # Expected errors when zone name guess is wrong + # Depending on server and API version, we expect certain error codes while trying + # to guess the correct zone name. Ignore. + if domain_name in e.response.url and e.response.status_code in [403, 404, 422]: + return + return super(_PowerDNSLexiconClient, self)._handle_http_error(e, domain_name)