131
131
signed_message['From'],
132
132
signed_message['Sender']))
133
133
signing_details = []
135
# NB: if this fails with a keyword argument error, you need the
136
# python-dkim 0.3-3.2 that adds it
137
136
dkim_result = dkim.verify(
138
137
signed_message.parsed_string, dkim_log, details=signing_details)
139
138
except dkim.DKIMException, e:
140
139
log.warning('DKIM error: %r' % (e,))
140
except dns.resolver.NXDOMAIN, e:
141
# This can easily happen just through bad input data, ie claiming to
142
# be signed by a domain with no visible key of that name. It's not an
144
log.info('DNS exception: %r' % (e,))
142
145
except dns.exception.DNSException, e:
143
146
# many of them have lame messages, thus %r
144
147
log.warning('DNS exception: %r' % (e,))
147
log.info('DKIM verification result=%s' % (dkim_result,))
149
# DKIM leaks some errors when it gets bad input, as in bug 881237. We
150
# don't generally want them to cause the mail to be dropped entirely
151
# though. It probably is reasonable to treat them as potential
152
# operational errors, at least until they're handled properly, by
153
# making pydkim itself more defensive.
155
'unexpected error in DKIM verification, treating as unsigned: %r'
157
log.info('DKIM verification result: trusted=%s' % (dkim_result,))
148
158
log.debug('DKIM debug log: %s' % (dkim_log.getvalue(),))
149
159
if not dkim_result: