DKIM verification with dnspython 2.0.0 raises an exception

Bug #1888583 reported by Hagai Helman Tov
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
dkimpy
Fix Released
High
Scott Kitterman

Bug Description

Recently a change was made to the dnspython API, and now dns.rrset.RRset.items does not return a list, but an OrderedDict (see https://github.com/rthalley/dnspython/commit/343be7c07efc57cad561ce1b69e54600ce01ce4f).

As a result, in an environment where dnspython 2.0.0 is installed, dkim.verify() raises the following exception:

  File "/home/user/.local/lib/python3.8/site-packages/dkim/dnsplug.py", line 34, in get_txt_dnspython
    return b"".join(r.items[0].strings)
KeyError: 0

It seems that replacing "r.items" with "list(r.items)" would solve the problem.

Revision history for this message
Anton Yuzhaninov (citrin) wrote :

Just using r[0] works for me. Haven't tested old dnspython though.

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

Thanks. We'll have to have something that will work with both, but this is a good basis to start looking into a fix.

Changed in dkimpy:
assignee: nobody → Scott Kitterman (kitterman)
importance: Undecided → High
milestone: none → 1.0.5
status: New → Triaged
Revision history for this message
Oliver Crow (ocrow) wrote :

For what it's worth, I have a script that stopped working because of this bug and was able to work around it by downgrading from dnspython 2.0.0 to 1.16.0.

pip3 uninstall dnspython
pip3 install dnspython==1.16.0

Revision history for this message
Scott Kitterman (kitterman) wrote : Re: [Bug 1888583] Re: DKIM verification with dnspython 2.0.0 raises an exception

On Friday, August 7, 2020 4:31:02 PM EDT you wrote:
> For what it's worth, I have a script that stopped working because of
> this bug and was able to work around it by downgrading from dnspython
> 2.0.0 to 1.16.0.
>
> pip3 uninstall dnspython
> pip3 install dnspython==1.16.0

That's the best approach until I have time to get this sorted.

Scott K

Revision history for this message
Hagai Helman Tov (hagai-helman-tov) wrote :

Here is a patch I tested with both dnspython 2.0.0 and dnspython 1.16.0, and it works with both.

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

Thanks. That works for me too. Tested with dnspython 1.16.0 and 2.0.0 on python3.8 and with dnspython 1.16.0 on python2.7. Committed to both master and stable/1.0 branches for the next releases.

Changed in dkimpy:
status: Triaged → Fix Committed
Revision history for this message
Scott Kitterman (kitterman) wrote :

2020-08-08 Version 1.0.5
    - Update dnsplug for DNS Python (dns) 2.0 compatibility (LP: #1888583)
    - Fix @param srv_id typos (LP: #1890532)

Changed in dkimpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.