From 4ca6b0204798701dca39ec0c7755e1ffeab0590b Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Sun, 3 May 2020 12:48:42 +0200 Subject: [PATCH] fix DKIM cname check --- app/dashboard/views/domain_detail.py | 2 +- app/dns_utils.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/dashboard/views/domain_detail.py b/app/dashboard/views/domain_detail.py index 534e68cd..1d5319cb 100644 --- a/app/dashboard/views/domain_detail.py +++ b/app/dashboard/views/domain_detail.py @@ -74,7 +74,7 @@ def domain_detail_dns(custom_domain_id): spf_errors = get_txt_record(custom_domain.domain) elif request.form.get("form-name") == "check-dkim": - dkim_record = get_cname_record(custom_domain.domain) + dkim_record = get_cname_record("dkim._domainkey." + custom_domain.domain) if dkim_record == dkim_cname: flash("DKIM is setup correctly.", "success") custom_domain.dkim_verified = True diff --git a/app/dns_utils.py b/app/dns_utils.py index b4a1a8ed..896d1b85 100644 --- a/app/dns_utils.py +++ b/app/dns_utils.py @@ -13,14 +13,15 @@ def _get_dns_resolver(): def get_cname_record(hostname) -> Optional[str]: - """Return the CNAME record if exists for a domain""" + """Return the CNAME record if exists for a domain, WITHOUT the trailing period at the end""" try: answers = _get_dns_resolver().query(hostname, "CNAME") except Exception: return None for a in answers: - return a + ret = a.to_text() + return ret[:-1] return None