From 957d6ac60bda29b80f012aeebf574a0d67d159cb Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 23 Nov 2020 12:59:31 -0500 Subject: Be more compatible with older dkimpy If we don't find a resolve() method in dnspython, just let dkimpy do its own lookups. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 61f5cb1..e50c8e3 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1636,7 +1636,12 @@ class LoreAttestationSignatureDKIM(LoreAttestationSignature): # self.native_verify() # return - if not dkim.verify(self.msg.as_bytes(), dnsfunc=dkim_get_txt): + # Do we have a resolve method? + if hasattr(_resolver, 'resolve'): + res = dkim.verify(self.msg.as_bytes(), dnsfunc=dkim_get_txt) + else: + res = dkim.verify(self.msg.as_bytes()) + if not res: logger.debug('DKIM signature did NOT verify') return self.good = True @@ -2353,10 +2358,6 @@ def dkim_get_txt(name: bytes, timeout: int = 5): if txtdata.find(b'p=') >= 0: _DKIM_DNS_CACHE[name] = txtdata return txtdata - except AttributeError: - # Try the native call - _DKIM_DNS_CACHE[name] = dkim.dnsplug.get_txt(name, timeout) - return _DKIM_DNS_CACHE[name] except dns.resolver.NXDOMAIN: pass _DKIM_DNS_CACHE[name] = None -- cgit v1.2.3