Skip to content

TLSA record mismatch after certificate renewal: fix 4.7.323

Your mail certificate renewed and DANE senders now defer mail with 4.7.323 tlsa-invalid. Compare the TLSA record with the key your server presents, find which of three causes you have, and stop the next renewal from repeating it.

Offensly Team··5 min read

A partner on Microsoft 365 forwards you this line from their message trace:

450 4.7.323 tlsa-invalid: The domain failed DANE validation

Your DNS did not change. Your mail server's certificate did: it renewed, and the TLSA record at _25._tcp.mx.example.com still describes the previous one. Senders that validate DANE, such as Exchange Online or Postfix with smtp_tls_security_level = dane, now see a certificate the record does not vouch for and keep the mail in their queue. Senders that ignore DANE deliver as usual, so the outage looks partial. Microsoft lists 4.7.323 as a server certificate that does not match the authentic TLSA record (Microsoft Learn).

A TLSA record mismatch after certificate renewal has three usual causes, and they need different fixes. Two commands tell them apart.

Compare the TLSA record with the key your server presents

Read the record first:

dig +dnssec +noall +answer _25._tcp.mx.example.com TLSA
_25._tcp.mx.example.com. 3600 IN TLSA 3 1 1 a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2
_25._tcp.mx.example.com. 3600 IN RRSIG TLSA 13 5 3600 ...

Note the first digit (3 pins your server's own key, 2 pins a CA) and the TTL in the second column. If dig returns SERVFAIL instead of an answer, DANE is not your problem yet; the signed chain is broken, and the DS record mismatch guide is the place to start.

Then hash the public key the server hands out on port 25. This is the value a 3 1 1 record must contain, a SHA-256 of the certificate's SubjectPublicKeyInfo:

openssl s_client -connect mx.example.com:25 -starttls smtp -servername mx.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -pubkey \
  | openssl pkey -pubin -outform DER \
  | openssl dgst -sha256

Only run checks like these against sites you own or are allowed to test.

SHA2-256(stdin)= f0e1d2c3b4a5f0e1d2c3b4a5f0e1d2c3b4a5f0e1d2c3b4a5f0e1d2c3b4a5f0e1

TLSA record mismatch after certificate renewal: which of three causes

The record starts with 3 and the hashes differ. The renewal generated a new private key. That is Certbot's default: it reuses a key only when told to with --reuse-key (Certbot docs). Most mismatches are this one.

The record starts with 2. Your leaf hash does not matter here; the record pins an issuing CA, and the CA changed. Let's Encrypt now issues from the YR1 and YR2 (RSA) and YE1 and YE2 (ECDSA) intermediates, and R10 to R14 and E5 to E9 are retired (Let's Encrypt, Chains of Trust). A 2 1 1 record for R11 stopped matching the day your renewal came from YR2. Add -showcerts to the s_client command and read the issuer line of the second certificate, for example i:C=US, O=Let's Encrypt, CN=YR2.

The hashes match, and senders still fail. Someone is reading an old RRset. Ask every authoritative server, not your resolver:

dig +short NS example.com
dig +short @ns1.example.net _25._tcp.mx.example.com TLSA
dig +short @ns2.example.net _25._tcp.mx.example.com TLSA

A secondary that has not pulled the new zone returns the old hash. If all of them agree, the senders hold the old record in cache and pick up the new one when the TTL runs out. One more variant: a server with both an RSA and an ECDSA certificate presents either one, depending on the sender, and each key needs its own record. A record for only one of them fails for some senders and not others.

Publish the hash of the key in use

At the DNS provider, replace the old value at _25._tcp.mx.example.com with the hash from the openssl output, keeping 3 1 1. The old key is no longer deployed, so its record matches nothing and can go. If your panel hides the TLSA type, the guide to adding DNS records shows where the record type list sits at common providers.

On Postfix you can skip the manual hashing. postfix tls output-server-tlsa -h mx.example.com prints a TLSA RRset for the key files in your Postfix configuration, one record per algorithm (postfix-tls(1)).

For a 2 1 1 setup, the quick fix is a record for the current intermediate. The lasting fix is to move to 3 1 1. Let's Encrypt keeps backup intermediates (YR3, YE3) that it may start issuing from at any time without warning, so a CA pin breaks again on a date you do not choose.

What not to touch while the queue backs up

Do not delete the DS record or turn off DNSSEC to make the error go away. Resolvers keep the old DS for its TTL, and in the meantime every lookup for your domain can fail, not only DANE.

Do not delete the TLSA record as a shortcut either. Senders that cached it keep failing until the TTL expires, exactly as long as with the corrected record, and you lose DANE on top.

Do not force another renewal. With Certbot defaults it produces yet another key and another mismatch.

Leave an expired certificate alone if its key matches. With usage 3, a DANE sender must ignore the certificate's expiry date (RFC 7671, section 5.1). The host name is a different story at Microsoft: Exchange Online rejects a certificate that does not carry the MX host name with 4.7.325 certificate-host-mismatch, even when the key matches.

Who stops getting your mail

Every sender that validates DANE, including all Exchange Online tenants, holds your mail and eventually returns it to their user. You see no bounce; your partners do. The fix is one DNS record, and the prevention below is one renewal setting.

Keep the next renewal from breaking it

With Certbot, run the renewal once with the flag; it is saved in the certificate's renewal configuration and applies to later automatic renewals:

certbot renew --cert-name mx.example.com --reuse-key --force-renewal

Now the key, and with it the 3 1 1 hash, stays the same across renewals. When you do want a new key, publish its hash next to the current one at least two TTLs before the new key goes live, then remove the old record once the switch works (RFC 7671, section 8.1). Postfix supports this with postfix tls new-server-key, which creates a key without deploying it and shows the TLSA commands for it.

Before you tell partners to retry, query each authoritative name server again and confirm all return the new hash. Microsoft's Remote Connectivity Analyzer has a DANE validation test that runs the same checks Exchange Online does (Exchange Team Blog). Senders that do not validate DNSSEC cannot use DANE at all; for them, MTA-STS does the same job of refusing downgraded TLS.

The Offensly advanced DNS check, free with an account on a verified domain, reads your DANE/TLSA records together with STARTTLS on your MX hosts and the DNSSEC chain they depend on.

Check your DANE and TLSA records with Offensly

Check your own domain in seconds

The free check reads your SPF, DKIM, DMARC and MX records and tells you exactly what to fix. No sign-up.