I'm trying to enter a 4028 bit DKIM key into DNS and it seems that I'm exceeding both the UDP 512 byte limit and also the maximum record size for a TXT record.
How does someone properly create a large key (with implied larger encoded size) and import it into DNS?
You need to split them in the text field. I believe that 2048 is the practical limit for key sizes. Split the text field into parts 255 characters or less. There is overhead for each split.
There are two formats for long fields.
Both of which will combine as "part onepart two". More details from Zytrax.
To generate my DKIM entry I insert my public key file and wrap it in quotation marks.
My public key file contains the following:
After editing the key in my dns zone file appears as follows:
DNS returns it as follow:
DNS treats it as one long string with no extra spaces where the lines are joined. All
" "
sequences are ignored.If it's Amazon Route 53 then don't use newlines (only spaces) between chunks.
See https://serverfault.com/a/763871/80856
If you use the poweradmin UI for pdns you can just enter the whole dkim string in the input field.
I know this post is ancient, but I found it today when querying "DKIM 2048 bit key with UltraDNS." My DNS team had attempted to split the key into two parts with quotes around them and a space between. That was causing UltraDNS to serve up 3 packets (the one in the center was empty) which caused inconsistent validation results.
What worked for me in the UltraDNS control panel was just to submit the entire record in quotes without multiple sets of quotes, delimiters, etc. Works as expected now.
It's not the prettiest script but it saves time and typo's on my named/bind hosts.
And if no newlines are needed you could add an
| tr '\n' ' '
It's OK if the record is greater than the UDP 512-byte limit because DNS will use TCP.
This should be transparent to the user, but sometimes buggy firewall appliances (such as Cisco PIX/ASA) will filter/block these larger queries.
If you are using MySQL/MariaDB as your DNS backend, like PowerDNS you could resize your content column.
Default PowerDNS content length is VARCHAR(255)
So your DKIM signature will be trimmed off to 255 characters
to fix this
just change the content size via the MySQL CLI / MariaDB CLI
restart your DNS Service (eg PowerDNS)