Email between servers is encrypted opportunistically. A sending server connects, sees that the receiver offers STARTTLS and upgrades the connection, but by default it does not verify who it is talking to, because the certificate on a mail server often does not match the name in the MX record and there is no trust anchor that both sides agree on. An attacker who can modify traffic can strip the STARTTLS offer or present a false certificate, and the sender will carry on without noticing. Two standards close this gap. MTA-STS publishes a policy over HTTPS; DANE, DNS-based Authentication of Named Entities, publishes the expected certificate in DNS itself and protects the records with DNSSEC. This article explains how DANE for SMTP works, what you need before you start, which record to publish, how to rotate certificates without breaking delivery and how it compares with MTA-STS. It is aimed at those who operate their own DNS and mail servers; if your mail is hosted, check what your provider already offers.
The building blocks
DANE for SMTP is defined in RFC 7672, on top of the general TLSA mechanism of RFC 6698. It has three parts that must all work.
- DNSSEC. The zone that contains the MX target host name (not necessarily your main domain) must be signed, with a valid chain of trust from the root. DNSSEC lets a resolver check that DNS answers have not been altered.
- TLSA records. For each MX host, you publish a record at
_25._tcp.<mx-host>that describes which certificate or public key the server will present on port 25. - A validating sender. The sending mail server must look up TLSA records with DNSSEC validation and refuse to deliver, or fall back safely, when the TLS check fails. Several well-known mail servers do this, including Postfix when configured to.
If the sender sees a validated TLSA record, it requires TLS and checks the certificate against the record; failure means the message is deferred, not delivered insecurely. If there is no TLSA record, the sender uses ordinary opportunistic TLS as before. This makes the system incrementally deployable.
Reading a TLSA record
_25._tcp.mx1.example.com. IN TLSA 3 1 1 0b9fa5a59eed715c26c1020c711b4f6ec42d58b0015e14337a39dad301c5afc3The record has four fields after the type. The first is the certificate usage, the second the selector, the third the matching type and the last the certificate association data (a hash).
| Field | Common value | Meaning |
|---|---|---|
| Usage | 3 (DANE-EE) | The record pins the server's own certificate or key; no CA chain is needed |
| Usage | 2 (DANE-TA) | The record pins a trust anchor, such as a private or public CA, higher in the chain |
| Selector | 1 (SPKI) | Hash the public key only, so the record survives renewals that keep the same key |
| Selector | 0 (full cert) | Hash the entire certificate; the record changes on every renewal |
| Matching type | 1 (SHA-256) | Association data is the SHA-256 hash |
| Matching type | 2 (SHA-512) | Association data is the SHA-512 hash |
The usual recommendation for SMTP is 3 1 1: pin the public key of the server's certificate with SHA-256. Usages 0 and 1 (PKIX-TA and PKIX-EE) are not used for SMTP because the standard says that certificate authority checks should not be the basis. A key that remains the same across certificate renewals means that you do not need to change DNS each time you renew.
Generating the hash
# SHA-256 hash of the certificate's public key (SPKI)
openssl x509 -in /etc/ssl/mail/fullchain.pem -noout -pubkey \
| openssl pkey -pubin -outform DER \
| openssl dgst -sha256 -binary | xxd -p -c 64Paste the output as the association data. Publish the record, wait for the TTL to pass and then test it with a DANE checker or a command such as swaks or openssl s_client -starttls smtp -dane, which verifies the chain against the record on supporting versions of OpenSSL.
Rolling it out
- Sign your zone with DNSSEC. Check that the registrar has the DS record and that validators such as DNSViz show a clean chain. See DNS records for email.
- Check the MX host names. TLSA is published for the host in the MX record. If your MX points at a host in someone else's zone, that zone must be signed and that operator must publish the TLSA records. See MX records.
- Use a stable key. Configure your certificate renewal to reuse the key pair, or plan a rollover.
- Publish the record(s) for the current key. If you run several MX hosts, publish a record for each of them.
- Test from outside. Send from a DANE-validating server and review its logs. Use online checkers to see the results.
- Monitor expiry. Monitor DNSSEC signature validity and the certificate dates. An expired signature on a DANE-protected domain stops mail.
Rotating keys safely
Key rotation is where DANE deployments fail. If you change the key on the server before DNS reflects it, validating senders will reject your certificate and defer mail. The safe order is: publish a new TLSA record for the new key alongside the old one, wait at least one TTL (and the maximum cache time of senders), deploy the new certificate and later remove the old record. With a 3 1 1 record that pins a key, you can also publish the next key in advance, so that either key is accepted at any time. Shorten the TTL a few days before a planned change. Automate the process or put it in a runbook.
DANE and MTA-STS compared
| Aspect | DANE | MTA-STS |
|---|---|---|
| Trust anchor | DNSSEC chain from the root | Public CA certificate and HTTPS policy file |
| Needs DNSSEC | Yes | No |
| Policy location | TLSA records in DNS | Text file on mta-sts.<domain> plus a DNS TXT record |
| Sender support | Common among self-run servers; less among the largest webmail providers | Supported by several of the large mailbox providers |
| Failure mode | Deferral on mismatch | Deferral or reporting, depending on mode |
| Operational risk | Signature expiry and key rollover | Certificate and policy hosting |
They are complementary. A domain that can support DNSSEC can publish both: DANE for senders that validate it and MTA-STS for those that support the HTTPS policy. Read MTA-STS and TLS-RPT setup to add reporting and the second layer. For the basics of encryption in transit, see email TLS and STARTTLS.
Common failure modes
- DNSSEC chain broken after a registrar or DNS provider change, which turns a valid zone into a bogus one for validators.
- Mismatch between the TLSA record and the key that the server presents, often after an automated renewal that generated a new key.
- TLSA record published for the wrong name, for example for the domain instead of the MX host, or for the wrong port.
- Several MX hosts with different certificates and records published for only some of them.
- Load balancers that present a different certificate to some connections.
DANE gives mail servers a way to authenticate each other that does not depend on a third party, but it asks for operational discipline. Start with a lab domain, monitor it for a few weeks and move production domains once rotation is routine. As always, confirm current software support and the guidance of your DNS and mail server vendors before you enable validation or publish records.
Secure your mail transport Use TLS on every connection and review your domain's transport security settings.
References and further reading
Frequently asked questions
What is DANE for SMTP?
A way to publish the expected certificate or key of a mail server in DNS, protected by DNSSEC, so that sending servers can authenticate the connection.
Which TLSA record should I use for SMTP?
Usually 3 1 1: DANE-EE usage, SPKI selector and a SHA-256 hash of the public key.
Do I need DNSSEC for DANE?
Yes. TLSA records are only trusted when the zone is signed and validated.
Is DANE better than MTA-STS?
Neither is strictly better. DANE needs DNSSEC and no HTTPS policy; MTA-STS needs no DNSSEC. They can be used together.
What happens if my TLSA record is wrong?
Validating senders will defer or reject mail to your domain. Test carefully and rotate keys with overlapping records.