Comment 4 for bug 1839487

Revision history for this message
Scott Kitterman (kitterman) wrote :

OK, that's definitely a bug. i= is optional and the milter is crapping out because it's not there. Does this help:

diff --git a/dkimpy_milter/__init__.py b/dkimpy_milter/__init__.py
index 0440967..6052b85 100644
--- a/dkimpy_milter/__init__.py
+++ b/dkimpy_milter/__init__.py
@@ -289,7 +289,11 @@ class dkimMilter(Milter.Base):
                 self.dkim_comment = str(x)
                 if milterconfig.get('Syslog'):
                     syslog.syslog("check_dkim: {0}".format(x))
- self.header_i = codecs.decode(d.signature_fields.get(b'i'), 'ascii')
+ try:
+ # i= is optional and dkimpy is fine if it's not provided
+ self.header_i = codecs.decode(d.signature_fields.get(b'i'), 'ascii')
+ except TypeError as x:
+ pass
             self.header_d = codecs.decode(d.signature_fields.get(b'd'), 'ascii')
             self.header_a = codecs.decode(d.signature_fields.get(b'a'), 'ascii')
             if res:

I mostly use it for signing, so that's definitely better tested. I have tested verification with signatures from multiple implementations, so it works at least in general. Mostly I see i= included in the signature (even though it's optional).

Thanks for the feedback and being willing to work on this. Once we get things sorted, I'll be glad to cut a new release (and get updates into Debian Stable).