Skip to content

Commit ab7a5d4

Browse files
committed
Try to print MTA-STS missing DNS policy error reason
When proper (not self-signed) TLS certificate is not provisioned on the domain yet, MiaB prints only: MTA-STS policy is missing: STSFetchResult.NONE which may confuse the administrator, as .well-known/mta-sts.txt file is already present and opens correctly. Print more human-friendly reason for this case.
1 parent 8664afa commit ab7a5d4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

management/status_checks.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,16 @@ def check_mail_domain(domain, env, output):
660660
else:
661661
output.print_error("MTA-STS policy is present but has unexpected settings. [{}]".format(policy[1]))
662662
else:
663-
output.print_error("MTA-STS policy is missing: {}".format(valid))
663+
certmessage = ''
664+
cert = get_ssl_certificates(env).get(domain)
665+
if not cert:
666+
certmessage = "No TLS certificate provisioned for this domain"
667+
else:
668+
cert_status = check_certificate(domain, cert['certificate'], cert['private-key'])
669+
if cert_status[0] != 'OK':
670+
certmessage = "TLS certificate is not valid"
671+
672+
output.print_error("MTA-STS policy is missing: {}".format(certmessage if certmessage else valid))
664673

665674
else:
666675
output.print_error("""This domain's DNS MX record is incorrect. It is currently set to '%s' but should be '%s'. Mail will not

0 commit comments

Comments
 (0)