Add new dkim.DnsTimeoutError class to report queried domain and selector

along with timeout error from dnspython (LP: #1873449)
This commit is contained in:
Scott Kitterman
2023-02-25 16:44:06 -05:00
parent 233a9699ed
commit b74452d9da
2 changed files with 12 additions and 2 deletions
+8
View File
@@ -101,6 +101,7 @@ __all__ = [
"ValidationError",
"AuthresNotFoundError",
"NaClNotFoundError",
"DnsTimeoutError",
"USE_ASYNC",
"CV_Pass",
"CV_Fail",
@@ -195,6 +196,9 @@ class NaClNotFoundError(DKIMException):
class UnknownKeyTypeError(DKIMException):
""" Key type (k tag) is not known (rsa/ed25519) """
class DnsTimeoutError(DKIMException):
""" DNS query for public key timed out """
def select_headers(headers, include_headers):
"""Select message header fields to be signed/verified.
@@ -796,6 +800,10 @@ class DomainSigner(object):
except binascii.Error as e:
self.logger.error('KeyFormatError: {0}'.format(e))
return False
except dns.exception.Timeout as e:
self.logger.error('DnsTimeoutError: Domain: {0} Selector: {1} Error message: {2}'.format(
sig[b'd'], sig[b's'], e))
return False
return self.verify_sig_process(sig, include_headers, sig_header, dnsfunc)