DANE/TLSA for SMTP¶
TLSA binds the SMTP certificate key to the DNSSEC-secured MX zone.
SMTP DANE requires DNSSEC-validated MX resolution and a validated TLSA publication, for example at _25._tcp.mail.example.org. A DNSSEC-signed PTR record is not required. RateMyMail can additionally make a bounded callback to a public MX on TCP port 25: banner, EHLO, STARTTLS and TLS certificate authentication against the validated TLSA records. No AUTH or MAIL/RCPT/DATA is sent. A positive finding confirms the reached endpoint at the evaluation time, not all MX/IPs or the original sending connection. Historical publication findings still establish only successful DNS inspection. See RFC 7672.
The bounded profile supports TLSA usage 2/3, selector 0/1 and matching 0/1/2. DANE-EE checks the leaf association independently of PKIX names and expiration; DANE-TA additionally requires a valid certificate path, allowed reference name and validity period. References include the MX name and the original receiving domain plus its expanded name derived from secure MX answers. Private, local and special-purpose addresses are excluded. Timeouts or connection failures remain unknown; certificate authentication failure and missing STARTTLS are separate findings. No automatic CRL/OCSP retrieval occurs.
Setup¶
Prepare your values and Debian packages. Commands use your domain and files.
Configure TLS and DNSSEC first. Calculate the TLSA value from your own certificate and publish the printed record as type TLSA at your provider:
set -euo pipefail
. /root/mailserver.env
digest=$(openssl x509 -in "/etc/letsencrypt/live/$MAILHOST/fullchain.pem" -pubkey -noout \
| openssl pkey -pubin -outform DER | openssl dgst -sha256 | awk '{print $NF}')
printf '_25._tcp.%s. IN TLSA 3 1 1 %s\n' "$MAILHOST" "$digest"
postconf -e 'smtp_dns_support_level=dnssec' 'smtp_tls_security_level=dane'
postfix check
systemctl reload postfix
Certificate renewal and key rotation¶
A 3 1 1 TLSA record binds the public SMTP key, not the certificate expiry date. Renewal with the same key preserves the hash; a new key requires a new TLSA record. Configure key reuse (--reuse-key) for the corresponding Certbot certificate lineage and verify its saved renewal parameters. For an existing lineage, use its actual --cert-name. The SMTP certificate may belong to a different lineage than the HTTPS certificate.
The basic reload hook in the TLS guide does not check a TLSA hash. For DANE, also compare the SPKI SHA-256 hash against published, DNSSEC-validated TLSA values before each activation. If an unexpected change should stop activation, Postfix must use a stable certificate set that the deploy hook replaces only after a successful check. Aborting a reload alone is insufficient: with direct Certbot live paths, a later Postfix restart may already load the new certificate. Monitor the retained certificate's expiry and report rejected activation as an operational failure.
For planned key rotation, publish the new TLSA hash alongside the old one and wait for the previous DNS TTL. Then activate the new SMTP key and certificate, verify the actually offered hash externally, and remove the old TLSA record afterwards. With manually maintained DNS, this sequence belongs in the renewal plan; calculating a hash does not update DNS.
Test¶
set -euo pipefail
. /root/mailserver.env
test "$(postconf -h smtp_dns_support_level)" = dnssec
test "$(postconf -h smtp_tls_security_level)" = dane
expected=$(openssl x509 -in "/etc/letsencrypt/live/$MAILHOST/fullchain.pem" -pubkey -noout \
| openssl pkey -pubin -outform DER | openssl dgst -sha256 | awk '{print $NF}')
actual=$(timeout 15 openssl s_client -starttls smtp -connect 127.0.0.1:25 \
-servername "$MAILHOST" -verify_hostname "$MAILHOST" -verify_return_error \
-CAfile /etc/ssl/certs/ca-certificates.crt -showcerts </dev/null 2>/dev/null \
| openssl x509 -pubkey -noout | openssl pkey -pubin -outform DER \
| openssl dgst -sha256 | awk '{print $NF}')
test "$actual" = "$expected"
printf 'PASS: Postfix DANE enabled; the SMTP key actually offered has SHA-256 %s\n' "$actual"
After DNS publication, check externally:
. /root/mailserver.env
delv "_25._tcp.$MAILHOST" TLSA
Expected externally: an authenticated TLSA record with 3 1 1 and exactly the calculated hash. TXT is not TLSA. Before rotating keys, publish the new TLSA alongside the old one and wait for TTL overlap; otherwise DANE senders may refuse delivery. smtp_tls_security_level=dane controls outgoing Postfix, while your TLSA publication protects incoming traffic.