Skip to content

Commit 3717ff1

Browse files
committed
Add dkimpy to requirements/base.txt, document key parse cost
1 parent 93bd58b commit 3717ff1

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

emails/signers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def __init__(self, selector: str, domain: str, key: str | bytes | IO[bytes] | No
2828
# Normalize to bytes
2929
privkey_bytes = privkey if isinstance(privkey, bytes) else str(privkey).encode()
3030

31-
# Validate key by attempting to parse it
31+
# Validate key early; dkim.sign() re-parses on each call but
32+
# the PEM parse cost is negligible vs the RSA operation (~0ms vs ~2.5ms).
3233
try:
3334
dkim.crypto.parse_pem_private_key(privkey_bytes)
3435
except UnparsableKeyError as exc:

requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ python-dateutil
55
requests
66
premailer>=2.8.3
77
puremagic
8+
dkimpy

0 commit comments

Comments
 (0)