From 19b142d1191af4cd332756d1707131cec2037cf9 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 | 10 ++++++---- 2 files changed, 10 insertions(+), 4 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..e238d2c 100644 --- a/certbot_dns_powerdns/dns_powerdns.py +++ b/certbot_dns_powerdns/dns_powerdns.py @@ -84,11 +84,13 @@ def __init__(self, api_url, api_key, ttl): self.provider = powerdns.Provider(config) def _handle_http_error(self, e, domain_name): + estr = str(e).lower() 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:') + # PowerDNS 4.0 and 4.1 compatibility + estr.startswith('422 client error: unprocessable entity for url:') or + # PowerDNS 4.2+ and PowerDNS-Admin compatibility + estr.startswith('403 client error: forbidden for url:') or + estr.lower().startswith('404 client error: not found for url:') ): return # Expected errors when zone name guess is wrong return super(_PowerDNSLexiconClient, self)._handle_http_error(e, domain_name)