- Add new DKIM.present function to allow applications to test if a DKIM
signature is present without doing validation (LP: #1851141)
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
Version 1.0.0
|
Version 1.0.0
|
||||||
- Add support for RFC 8460 tlsrpt DKIM signature processing (LP: #1847020)
|
- Add support for RFC 8460 tlsrpt DKIM signature processing (LP: #1847020)
|
||||||
- Add new timeout parameter to enable DNS lookup timeouts to be adjusted
|
- Add new timeout parameter to enable DNS lookup timeouts to be adjusted
|
||||||
|
- Add new DKIM.present function to allow applications to test if a DKIM
|
||||||
|
signature is present without doing validation (LP: #1851141)
|
||||||
- Drop usage of pymilter Milter.dns in dnsplug since it doesn't support
|
- Drop usage of pymilter Milter.dns in dnsplug since it doesn't support
|
||||||
havine a timeout passed to it
|
havine a timeout passed to it
|
||||||
|
|
||||||
|
|||||||
@@ -872,6 +872,11 @@ class DKIM(DomainSigner):
|
|||||||
self.signature_fields = dict(sigfields)
|
self.signature_fields = dict(sigfields)
|
||||||
return b'DKIM-Signature: ' + res
|
return b'DKIM-Signature: ' + res
|
||||||
|
|
||||||
|
#: Checks if any DKIM signature is present
|
||||||
|
#: @return: True if there is one or more DKIM signatures present or False otherwise
|
||||||
|
def present(self):
|
||||||
|
return (len([(x,y) for x,y in self.headers if x.lower() == b"dkim-signature"]) > 0)
|
||||||
|
|
||||||
#: Verify a DKIM signature.
|
#: Verify a DKIM signature.
|
||||||
#: @type idx: int
|
#: @type idx: int
|
||||||
#: @param idx: which signature to verify. The first (topmost) signature is 0.
|
#: @param idx: which signature to verify. The first (topmost) signature is 0.
|
||||||
|
|||||||
@@ -300,6 +300,16 @@ p=11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo="""
|
|||||||
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
|
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
|
||||||
self.assertTrue(res)
|
self.assertTrue(res)
|
||||||
|
|
||||||
|
def test_present(self):
|
||||||
|
# Test DKIM.present().
|
||||||
|
d = dkim.DKIM(self.message,signature_algorithm=b'rsa-sha256')
|
||||||
|
present = d.present()
|
||||||
|
self.assertFalse(present)
|
||||||
|
sig = d.sign(b"test", b"example.com", self.key)
|
||||||
|
signed = sig + self.message
|
||||||
|
d2 = dkim.DKIM(signed)
|
||||||
|
present = d2.present()
|
||||||
|
self.assertTrue(present)
|
||||||
|
|
||||||
def test_badly_encoded_domain_fails(self):
|
def test_badly_encoded_domain_fails(self):
|
||||||
# Domains should be ASCII. Bad ASCII causes verification to fail.
|
# Domains should be ASCII. Bad ASCII causes verification to fail.
|
||||||
|
|||||||
Reference in New Issue
Block a user