jaizendra-netizen / dkim-record-check
PHP CLI and library: check DKIM TXT records for tag problems, revoked keys and weak RSA keys, reading the modulus length straight from the key's DER bytes.
Package info
github.com/jaizendra-netizen/dkim-record-check
Type:project
pkg:composer/jaizendra-netizen/dkim-record-check
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-29 22:39:51 UTC
README
PHP command line tool and library. Give it a text file of DKIM DNS TXT records, one per line, and it checks each one: v must be DKIM1 when present, k must be rsa or ed25519 (rsa when absent), p is required, and an empty p is reported as a revoked key rather than an error. Repeated tags and t=y (testing mode) are warnings. For RSA keys it decodes p, reads the DER bytes of the public key itself (no openssl extension needed) and reports the modulus length in bits: under 1024 is an error, exactly 1024 is a warning because it is the minimum allowed (RFC 8301), and 2048 or more is ok. A size between 1025 and 2047 bits is also reported as a warning, a choice made by this tool because the rule above does not cover it. For ed25519 it checks that p decodes to 32 bytes. A p that is not valid base64 or not a public key structure is an error.
Part of the OneGTMLab free GTM tools. Background on the idea: DKIM.
Install
composer require jaizendra-netizen/dkim-record-check
Use
Input is a text file with one record per line: the selector, a TAB, then the TXT value exactly as the DNS provider shows it. The value may be wrapped in double quotes and may be several quoted chunks, which are joined. Blank lines and lines starting with # are ignored; a line without a TAB is reported as an error record. Tags other than v, k, p and t are read but not checked. The sample holds real public keys (1024 and 2048 bit RSA) made for this repository; the private keys were deleted. The command exits 1 if any record has an error, so it can gate a send; the example below prints the exit code after the report. An unreadable or empty file, or a missing argument, exits 2.
$ php bin/dkim-record-check sample.txt; echo "exit code: $?"
s1: rsa, 2048 bits, ok
s2: rsa, 1024 bits, warning
warning: 1024 bits is the minimum allowed, use 2048 or more
s3: rsa, no key size, revoked
info: p is empty, so the key is revoked
s4: rsa, 2048 bits, warning
warning: t contains y: the key is marked as in testing mode
s5: rsa, no key size, error
error: p tag is missing
records: 5 (ok 1, warning 2, error 1, revoked 1)
exit code: 1
Test
php tests/run.php
Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.