diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-11-23 12:59:31 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-11-23 12:59:31 -0500 |
commit | 957d6ac60bda29b80f012aeebf574a0d67d159cb (patch) | |
tree | 3f069efc391df3ba9e2696c3f9ff28421c7cb193 | |
parent | 8d70b9869f785d8524b2c4d114f2afcb47b6df56 (diff) | |
download | b4-957d6ac60bda29b80f012aeebf574a0d67d159cb.tar.gz |
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 <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 11 |
1 files 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 |