dknewkey & OpenSSL 3 generated RSA key doesn't work
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dkimpy |
Fix Released
|
Medium
|
Unassigned |
Bug Description
Hi,
I'm setting up dkimpy-milter on Ubuntu 22.04. RSA keys generated with dknewkey are not parseable be dkimpy:
XXX:~/test$ dknewkey test
generating test.key
extracting test.key
writing RSA key
writing test.dns
XXX:~/test$ dkimsign s1 example.com test.key < ~/test.mail
Unparsable private key: Unexpected tag (got 30, expecting 02)
This is because of OpenSSL 3 default PKCS#8 format, man openssl-rsa:
-traditional
When writing a private key, use the traditional PKCS#1 format instead of the PKCS#8 format.
After converting key it works:
XXX:~/test$ openssl rsa -in test.key -traditional -out test.key.trad
writing RSA key
XXX:~/test$ dkimsign s1 example.com test.key.trad < ~/test.mail
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=example.com;
<email address hidden>; q=dns/txt; s=s1; t=1655303489; h=from : to : subject :
from; bh=cuaAHru3/
b=WdnSt2BM3EzT
T5lFakKyMBYFKw
skTl/Oj93YpqoW
Z1gX0MBGL2MNDN
Yc3Li5gM/
Also, finding the issue took quite a while as dkimpy-milter with KeyTable/SignTable didn't log any errors. Only when testing with Domain/
dkimpy-
Related branches
- Scott Kitterman: Approve
-
Diff: 150 lines (+60/-6)5 files modifieddkim/asn1.py (+3/-0)
dkim/crypto.py (+16/-3)
dkim/tests/data/2048_testkey_PKCS8.key (+28/-0)
dkim/tests/data/2048_testkey_PKCS8.key.pub.txt (+1/-0)
dkim/tests/test_dkim_rsavariants.py (+12/-3)
Changed in dkimpy: | |
status: | Fix Committed → Fix Released |
FWIW I ran into this same issue on Debian testing (python3-dkim 1.0.5-2).