fix DKIM cname check
This commit is contained in:
parent
9991723f5e
commit
4ca6b02047
|
@ -74,7 +74,7 @@ def domain_detail_dns(custom_domain_id):
|
||||||
spf_errors = get_txt_record(custom_domain.domain)
|
spf_errors = get_txt_record(custom_domain.domain)
|
||||||
|
|
||||||
elif request.form.get("form-name") == "check-dkim":
|
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:
|
if dkim_record == dkim_cname:
|
||||||
flash("DKIM is setup correctly.", "success")
|
flash("DKIM is setup correctly.", "success")
|
||||||
custom_domain.dkim_verified = True
|
custom_domain.dkim_verified = True
|
||||||
|
|
|
@ -13,14 +13,15 @@ def _get_dns_resolver():
|
||||||
|
|
||||||
|
|
||||||
def get_cname_record(hostname) -> Optional[str]:
|
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:
|
try:
|
||||||
answers = _get_dns_resolver().query(hostname, "CNAME")
|
answers = _get_dns_resolver().query(hostname, "CNAME")
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for a in answers:
|
for a in answers:
|
||||||
return a
|
ret = a.to_text()
|
||||||
|
return ret[:-1]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue