Skip to content
AdminKit

How do you verify DANE/TLSA for a mail server?

DANE uses a DNSSEC-signed TLSA record (RFC 6698) to publish exactly which TLS certificate a mail server should present, so a receiver can detect a forged certificate instead of trusting any certificate authority. RFC 7672 defines how SMTP servers use this to make STARTTLS downgrade-resistant. AdminKit's SSL/TLS check tool shows the certificate a mail server actually presents.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • A TLSA record at _25._tcp.<mx-host> tells sending servers which certificate or public key your mail server must present. It only counts if DNSSEC validates it.
  • RFC 7672 recommends 3 1 1 (DANE-EE, public key, SHA-256) for SMTP, with 2 0 1 as the second choice. Usages 0 and 1 should not be used on port 25.
  • Once a sender finds a valid, signed TLSA record, it must not deliver to that host without STARTTLS. That is what stops downgrade attacks.
  • AdminKit’s DNS lookup doesn’t resolve TLSA. Use dig for the record, AdminKit’s DNSSEC check for the zone, and openssl s_client -starttls smtp for the certificate.
  • Publish the new key’s TLSA record before you change keys, or DANE-enabled senders will refuse your mail until DNS catches up.

What does a TLSA record actually pin?

A TLSA record, defined in RFC 6698, lets a domain publish — in DNS — exactly which certificate or public key a given server is supposed to present, instead of leaving trust entirely up to whichever certificate authority issued the one a client happens to receive. Every publicly-trusted certificate a client might receive instead is required to meet the CA/Browser Forum’s Baseline Requirements, but that still means trusting whichever of the many CAs in a client’s trust store issued it — the specific assumption DANE/TLSA removes by pinning one certificate directly. For mail specifically, RFC 7672 defines how a sending SMTP server uses this to upgrade opportunistic STARTTLS into something an attacker on the network path can’t silently strip or downgrade — see does your mail server actually enforce STARTTLS? for why opportunistic STARTTLS needs a mechanism like this at all.

The record name itself encodes the service it protects: _port._protocol.hostname, so a TLSA record for SMTP on the standard port looks like _25._tcp.mail.example.com. That naming convention is why a TLSA record is specific to one service and port on a host, not a blanket statement about every service the hostname runs. For inbound mail, the host name is the one in your MX record, not your bare domain.

RFC 7671 §2.1 gives an example record for a mail server, quoted here:

_25._tcp.mail.example.com. IN TLSA 2 0 1 (
                           E8B54E0B4BAA815B06D3462D65FBC7C0
                           CF556ECCF9F5303EBFBB77D022F834C0 )

2 0 1 means DANE-TA, full certificate, SHA-256, and the hex string is the digest. The next sections explain each number.

How does a sending server decide to use DANE?

RFC 7672 sets out the sequence a DANE-aware sending server follows for each MX host. Every step has to succeed with DNSSEC-validated (“secure”) answers, otherwise the sender falls back to ordinary opportunistic TLS:

StepWhat the sender checks (RFC 7672)If it isn’t secure or doesn’t exist
1. MX lookupThe domain’s MX records, via a DNSSEC-validated lookup (§2.2.1)Pre-DANE opportunistic TLS, possibly cleartext
2. Address lookupThe MX host’s A/AAAA records (§2.2.2)TLSA lookup is skipped for that host
3. TLSA lookup_25._tcp.<mx-host>, following CNAMEs, with every step secure (§2.2.3)DANE doesn’t apply to that host
4. STARTTLSIf a secure TLSA record exists, the sender “MUST NOT deliver mail via the corresponding host unless a TLS session is negotiated via STARTTLS” (§2.2.3)No delivery to that host without TLS
5. Certificate matchThe server’s certificate or key must match one of the TLSA records (§3)The sender “MUST NOT deliver mail via a server whose certificate chain fails to match” (§9.1)

Step 4 is the security gain. Without DANE, an attacker who removes the STARTTLS offer from the server’s reply can make the sender fall back to plaintext. With a signed TLSA record, falling back is not allowed. RFC 7672 §2.2.1 also says MX preference still wins: a backup MX with TLSA records “MUST NOT preempt” a preferred MX without them, so every MX host needs its own records.

What do the four fields mean?

A TLSA record’s data has four parts, read in order:

  1. Certificate Usage — which trust model applies: 0 (PKIX-TA) and 1 (PKIX-EE) still require the certificate to chain to a public CA, just pinning which CA or which exact certificate within that chain; 2 (DANE-TA) and 3 (DANE-EE) don’t require a public CA at all, pinning a custom trust anchor or the end-entity certificate directly. RFC 7671’s operational guidance recommends 3 (DANE-EE) for new deployments — pin the actual server certificate, independent of any CA.
  2. Selector — whether the match is against 0 (the full certificate) or 1 (only its SubjectPublicKeyInfo, the public key and its algorithm). Selector 1 is generally preferred because it survives a certificate renewal that reuses the same key pair, which 0 wouldn’t.
  3. Matching Type — 0 (the full data, rarely used), 1 (a SHA-256 hash), or 2 (a SHA-512 hash) of whatever the selector pointed at. RFC 7671 §2 says SHA-256 is the only one “mandatory to implement”, and that servers “SHOULD NOT exclusively publish SHA2-512(2) digests.”
  4. Certificate Association Data — the actual hash value to compare against.

The registered values are listed in IANA’s DANE parameters registry. For SMTP, RFC 7672 narrows the choice further:

RecordMeaningRFC 7672 position for port 25
3 1 1DANE-EE, public key, SHA-256Recommended (§3.1)
2 0 1DANE-TA, full trust-anchor certificate, SHA-256Second choice (§3.1)
3 0 1DANE-EE, full certificate, SHA-256Valid, but breaks at every renewal
0 x x / 1 x xPKIX-TA / PKIX-EE, still tied to public CAs“SHOULD NOT” be published (§3.1.3)

With DANE-EE, RFC 7672 §3.1.1 says the server “MUST be considered authenticated even if none of the names in the certificate match”, and RFC 7671 §5.1 says the certificate’s expiry date “MUST be ignored”. The TLSA record and its DNSSEC signatures carry the trust, so a self-signed certificate works for DANE senders, and in RFC 7671’s words, missing the expiry date “no longer causes an outage”.

Why is it worthless without DNSSEC?

A TLSA record is only as trustworthy as the DNS answer carrying it. If an attacker can intercept or spoof DNS responses — the same capability needed to redirect mail delivery in the first place — they could forge a matching fake TLSA record alongside a forged certificate, defeating the entire mechanism. This is why RFC 7672 only uses TLSA records that validate as “secure” under DNSSEC: per §2.2.3, if none of the candidate names yields a secure TLSA record, “the SMTP client is free to use pre-DANE opportunistic TLS (possibly even cleartext)”. An unsigned TLSA record is simply not used. See DNSSEC: what it actually protects for what that validation chain actually covers and the most common ways it breaks.

The zone that has to be signed is the one holding the MX host’s records, which isn’t always your own. If your MX points at a provider’s host, the provider’s zone must be signed and the provider must publish the TLSA records. RFC 7672 §2.2.1 notes that hosted domains whose own zone isn’t signed “may still benefit from the provider’s TLSA records” if senders choose to use them.

How do you check a mail server’s TLSA record today?

  1. Find the MX hosts. Run AdminKit’s MX lookup for your domain. Each MX host needs its own TLSA record.
  2. Query the TLSA record. AdminKit’s live DNS lookup tool doesn’t resolve the TLSA type — it covers A, AAAA, MX, TXT, NS, CAA, PTR, SOA and CNAME — so check it directly with a command-line resolver. An empty answer means no TLSA record is published for that service and port.
  3. Confirm the zone is DNSSEC-signed. A TLSA record published in an unsigned zone provides no real protection, for the reason above. AdminKit’s DNSSEC check asks a validating resolver whether a zone is secure, insecure or bogus. Run it for the zone that holds the MX host, and see DNSSEC: what it actually protects for how to read the result.
  4. Confirm the pinned key matches what the server actually presents on port 25, using the commands in the next two sections.

Steps 2 and 3 on the command line look like this. The output is an illustrative example with documentation names and a shortened digest, not a captured response:

$ dig +dnssec +noall +answer +multi _25._tcp.mail.example.com TLSA
_25._tcp.mail.example.com. 3600 IN TLSA 3 1 1 (
                           8B6A0F1C9E2D...7C40 )
_25._tcp.mail.example.com. 3600 IN RRSIG TLSA 13 5 3600 (...)

An RRSIG next to the record shows it is signed. Whether your resolver validated it shows as the ad flag in the header of the full dig output, which you only get from a validating resolver.

AdminKit’s SSL/TLS check is not a substitute for the port 25 test. It runs a direct TLS handshake to the host’s HTTPS port, so it shows the certificate the host serves on the web. That is only the same certificate if the mail server and web server share one. See how to read a TLS/SSL certificate check result for the fields it reports.

How do you compute the hash to compare?

For a 3 1 1 record, the association data is the SHA-256 digest of the certificate’s public key in DER form. The Postfix TLS documentation gives this pipeline for a certificate file, quoted here with its sample output:

$ openssl x509 -in cert.pem -noout -pubkey |
    openssl pkey -pubin -outform DER |
    openssl dgst -sha256 -c
(stdin)= 64:3f:1f:f6:e5:1e:d4:2a:...:8b:fc:09:1a:61:98:b5:bc:7c:60:58

Drop the -c option to get the digest without colons, which is the form a TLSA record uses. Compare it with the last field of the published record, ignoring case. If they differ, either the record is stale after a key change, or the server is presenting a different certificate than the domain published, and DANE-enabled senders will refuse to deliver to that host. Postfix’s guide also says, “As a best practice, publish ‘3 1 1’ TLSA associations”, because they “continue to work unmodified when a certificate is renewed with the same public/private key pair.”

How do you test the whole chain with OpenSSL?

openssl s_client can do the STARTTLS exchange on port 25 and check the result against TLSA data you give it. The OpenSSL manual documents -starttls smtp, -dane_tlsa_domain and -dane_tlsa_rrdata, and gives this example, quoted with its digest values shortened:

$ openssl s_client -brief -starttls smtp \
    -connect smtp.example.com:25 \
    -dane_tlsa_domain smtp.example.com \
    -dane_tlsa_rrdata "2 1 1  B111DD8A1C2091A89BD4FD60C57F0716CCE50FEEFF8137CDBEE0326E 02CF362B" \
    -dane_tlsa_rrdata "2 1 1  60B87575447DCBA2A36B7D11AC09FB24A9DB406FEE12..."

Use the values from your own dig output. When authentication succeeds, the manual says the output reports the depth at which a TLSA record matched. OpenSSL doesn’t fetch or validate the TLSA record itself here, so this tests the certificate match. DNSSEC validation is still steps 2 and 3 above.

How do you change a certificate without breaking DANE?

The rule is to publish first and switch second. RFC 7672 §4 says “Two TLSA records MUST be published before employing a new EE or TA public key or certificate: one matching the currently deployed key and the other matching the new key.” RFC 7671 §8.1 adds the timing: publish the new record “at least two Times to Live (TTLs) or longer before the new chain is deployed.” The sequence, illustrated with documentation names and shortened digests:

; 1. Before: one record for the key in use
_25._tcp.mail.example.com. IN TLSA 3 1 1 01d09d19c2139a46...

; 2. At least two TTLs before the key change: both keys
_25._tcp.mail.example.com. IN TLSA 3 1 1 01d09d19c2139a46...
_25._tcp.mail.example.com. IN TLSA 3 1 1 7aa7a5359173d05b...

; 3. After the new key is live and verified: new key only
_25._tcp.mail.example.com. IN TLSA 3 1 1 7aa7a5359173d05b...

If you renew with the same key pair, a 3 1 1 record needs no change at all. Automated certificate renewal that generates a new key each time is the case to watch: it needs the TLSA update built into the same process.

Do DANE and MTA-STS compete?

No. MTA-STS (RFC 8461) protects against the same STARTTLS-stripping downgrade using a web-hosted policy file instead of a DNSSEC-signed DNS record, which makes it easier to deploy but dependent on separate web hosting and its own CA-issued certificate. DANE needs no web policy but only works at all once a zone is DNSSEC-signed. Running both means a sending server that supports either mechanism gets downgrade protection; neither one alone covers every sending server. How to publish and test MTA-STS covers the other half. This guide is part of AdminKit’s email authentication cluster of mail-transport-security guides and tools.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

What problem does DANE/TLSA solve that a normal CA-issued certificate doesn't?

Ordinary TLS trusts any certificate authority in the client's trust store to vouch for a server's certificate — if any trusted CA is tricked or compromised into mis-issuing a certificate for a domain, a client has no DNS-level way to notice. A TLSA record lets the domain itself publish, in DNS, exactly which certificate or key it actually uses, so a validating client can confirm the certificate presented in the handshake matches what the domain published, independent of which CA (if any) issued it.

What do the four fields in a TLSA record mean?

RFC 6698 defines four fields: Certificate Usage (0=PKIX-TA, 1=PKIX-EE, 2=DANE-TA, 3=DANE-EE — which trust model applies), Selector (0=match the full certificate, 1=match only its SubjectPublicKeyInfo), Matching Type (0=full data, 1=SHA-256 hash, 2=SHA-512 hash), and the Certificate Association Data itself (the actual hash or data to match). RFC 7671 §5.1 recommends usage 3 (DANE-EE, pinning the end-entity certificate directly) with selector 1 and matching type 1 "at most sites", and RFC 7672 §3.1 makes the same recommendation for SMTP, with "2 0 1" as the second choice. For port 25, RFC 7672 §3.1.3 says records SHOULD NOT use usages 0 or 1.

Why does a TLSA record require DNSSEC specifically?

Because a TLSA record is only trustworthy if its own origin can be verified. Without DNSSEC signing the zone, an attacker who can intercept or spoof DNS responses could forge both the TLS certificate and a matching fake TLSA record at the same time, defeating the entire point. RFC 7672 §2.2.3 says that if no "secure" (DNSSEC-validated) TLSA records are found, the sending server is free to use pre-DANE opportunistic TLS, so an unsigned TLSA record is simply not used. The MX records themselves must also be obtained through a DNSSEC-validated lookup (RFC 7672 §2.2.1).

Can AdminKit check my mail server's TLSA record directly?

Not the TLSA record lookup itself — AdminKit's DNS lookup tool resolves A, AAAA, MX, TXT, NS, CAA, PTR, SOA and CNAME, and TLSA isn't in that list, so a TLSA query needs a command-line resolver such as `dig _25._tcp.mail.example.com TLSA`. AdminKit's DNSSEC check does help with the prerequisite: it reports whether a zone validates as secure, insecure or bogus. AdminKit's SSL/TLS check runs a direct TLS handshake to a hostname's HTTPS port, so it shows the certificate a mail host serves on the web, not the one it presents after STARTTLS on port 25. For the SMTP certificate itself, use openssl s_client -starttls smtp.

Do I need DANE if I already publish MTA-STS?

They solve the same downgrade problem with different mechanisms and aren't mutually exclusive. MTA-STS (RFC 8461) publishes a policy over HTTPS, discovered via a plain DNS TXT record, and doesn't require DNSSEC — easier to deploy but dependent on web hosting and a CA-issued certificate for the policy fetch itself. DANE/TLSA pins the mail server's own certificate directly via a DNSSEC-signed record and needs no separate web policy, but only works if the domain's zone is DNSSEC-signed. Many mail operators run both so a sending server enforcing either one gets the downgrade protection; see our guide on STARTTLS enforcement for how MTA-STS fits into the same picture.

What happens to TLSA records when I renew my mail server's certificate?

With the recommended 3 1 1 record, nothing, as long as the renewed certificate keeps the same key pair: the record hashes the public key, not the certificate. If the key changes, RFC 7672 §4 says to publish a TLSA record for the new key alongside the old one first, and RFC 7671 §8.1 says to do that at least two TTLs before the new key goes live. Remove the old record afterwards.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.