Skip to content
Ooops - Navigation options above may not work on this device, please switch to Desktop layout if you need them.
If you just need to contact me privately click here

Easily Configure DANE

DANE, short for DNS-based Authentication of Named Entities, primarily used for SMTP and SIP, is a protocol for securely publishing keys and certificates through cryptographically secured DNS using DNSSEC.

If your domain does not have DNSSEC configured - STOP! This is NOT going to work, you will first need to configure DNSSEC, and this example uses the postfix MTA, not sendmail, not exim, and sure as hell not qmail, the DNS is the main part that gets people anyway, your MTA should have a wiki on how to interface with DANE.

I looked at DANE once a couple of years ago, but the documentation was poor, the few detailed articles I found was rambling, made my eyes feel like they were ready to bleed, so I moved on, I, like many of us, don't have hours to read an article that's so in-depth it's more or less like a scientific publication designed to bamboozle the average person, I like small summaries of what something is and does, and bullet points on how to configure it, not remind me of reading War and Peace, so I'll give it to you short and sweet...

The first thing to remember is that if your domain is example.com, but your MX record and your mail server is mail.example.com, then mail.example.com is the name that must have the SSL cert we need to work with, likely you do already since it's pretty much a given when sending and receiving Email, so basically, in all the below examples, replace example.com with your domain, and if you just use your domain name as the MX, then remove references to the preceding mail dot.

Open a console on the server where your MX's certificate is located, if using Lets Encrypt and Acme.sh, it's going to be /root/.acme.sh/example.com/example.com.cer however if your silly enough to still be using certbot, find where ever certbot hides the cert, or change to acme.sh :-P

Next run the following commands which will generate the output needed to add into the primary DNS servers zone file, for example.com that's -

openssl x509 -in ~/.acme.sh/mail.example.com_ecc/mail.example.com.cer -noout -pubkey  | openssl pkey -pubin -outform DER | openssl dgst -sha256
It should give you output like:
(stdin)= 5485485455956854-6klhjy55555xxxx555

That's the hash we need, open a new window and login to your DNS server, edit your zone file, or add a new entry if you use some third party web interface, in your zone file, add a new entry
_25._tcp.mail.example.net.     TLSA     3 1 1
then paste the hash you just generated (the bits after the equals sign to the end of the line), into your zone file on the same line right after the 3 1 1, so it looks something like this...

_25._tcp.mail.example.net.     TLSA     3 1 1 5485485455956854-6klhjy555.....555
Remember to increment the zones serial, then save the file and run rndc reload, wouldn't hurt to check the logs for any issues either.

Now we can test using dig, just remember to use your host name and name server...

dig TLSA _25._tcp.mail.example.com @ns1.example.com +dnssec
You should see a bunch of output, the important bit we want to see is the ANSWER section, something along the lines of...

_25._tcp.mail.example.net.   86400 IN  TLSA 3 1 1 5485485455956854-6klhjy555  444555
_25._tcp.mail.example.net. 86400 IN RRSIG TLSA 13 5 86400 xxx yyy zzz

If you do not see an ANSWER section and get, say an AUTHORITY section, something went wrong, double check you didn't include a line break, check logs for any hints as well. If you do see that in an ANSWER section, your 99% sorted, all we have to do now is add or change some settings in your MTA, as I use postfix, add or change the following settings in /etc/postfix/main.cf
smtp_dns_support_level = dnssec
smtp_tls_security_level = dane
smtpd_tls_security_level = may

run postfix reload and that's it, yes, you really are done, postfix will now validate inbound and your published for receivers to validate your outbound connection, well for those who have figured out already how to do it :-D

Postfix will also fail safe, meaning if there is a problem, mail will still succeed.

Lastly, time for those final tests, I suggest using https://dane.sys4.de and https://www.uriports.com/tools/dane-validator to validate your configuration, and no matter what, monitor your logs for a few days at least, just to be on the safe side ;-)


Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Form options

Multiple DNSBL checks will be performed on submission of your comments.
Accepted comments will then be subject to moderation approval before displaying.