Skip to content

DANE: pinning a mail server's certificate in DNS

Updated

A sending mail server normally accepts almost any certificate from the server it delivers to, because it has no way to know which one is right. DANE (RFC 6698, applied to mail by RFC 7672) gives it one: a record in DNS that says which certificate, or which key, that mail server will present.

The record

A TLSA record is published for each mail server, at a name made from its SMTP port and the server name. It has three numbers and then the data that pins the certificate.

_25._tcp.mx1.example.net.  TLSA  3 1 1 (the SHA-256 hash of the server's public key)
  • The first number is the usage. For mail, senders use 3 (the server's own certificate or key) or 2 (a trust anchor). Usage 0 and 1 are ignored for mail
  • The second is the selector: 1 pins the public key, which survives a certificate renewal if the key is kept
  • The third is the matching type: 1 is a SHA-256 hash, the usual choice

It needs DNSSEC

If an attacker could forge the DNS answer, they could forge the pin as well. So senders only use a TLSA record when the answer is verified with DNSSEC. A TLSA record in an unsigned zone does nothing. The check on this site marks a record as verified only when the resolver says it validated the answer.

Before you publish one

  • Sign the DNS zone that holds the mail server's name with DNSSEC
  • Publish a record for every mail server you list in MX, or senders fall back to ordinary encryption for the others
  • When you change the key or the certificate, publish the new record first, wait for the old one to expire from caches, and only then switch
  • Many hosted mail providers publish DANE for their own servers. Ask yours before doing it by hand

Check a domain's mail servers for DANE