Karta.DANE (Karta v1.0.0)

DANE for outbound SMTP (RFC 7672): the TLSA records of a delivery target.

lookup/3 finds them (RFC 7672 §2.2):

  • DANE applies only to a target whose MX answer and address answer were validated with DNSSEC (mx_secure and address_secure, see Karta.Outbound.MXResolver); an address literal never has DANE.
  • The candidate TLSA base domains are the host's name after CNAMEs, then the host's name as the MX record gave it, when they differ (§2.2.3). For each, _<port>._tcp.<base> is looked up (port 25 unless delivery uses another); the first validated TLSA RRset decides, and its candidate becomes the TLSA base domain.
  • An answer that was not validated, or a validated answer that there are no TLSA records, leads to the next candidate; with none left, DANE does not apply.
  • A lookup that fails (a timeout, SERVFAIL, which a validating resolver also answers for a bogus record) is an error: the server must not be used (§2.1.2).

Results:

  • :none - DANE does not apply: delivery as without it;
  • {:ok, %Karta.DANE{}} - base (the TLSA base domain), records (the RRset) and usable (Karta.DANE.TLSA.usable/1). With usable records the server must authenticate with them; without, it must still use TLS, unauthenticated (§2.2);
  • {:error, reason} - the lookup failed (Karta.DNS.Resolver.error/0).

Summary

Functions

The TLSA records of target (a Karta.Outbound.MXResolver target) for delivery to port. dns are the options of Karta.DNS.lookup/3. See the module doc.

:ssl client options that authenticate the server with the usable records of dane (RFC 7672 §3)

The RRset in presentation form, one record a line, for the policy-string of TLS reports (RFC 8460 §4.4).

Types

result()

@type result() :: :none | {:ok, t()} | {:error, Karta.DNS.Resolver.error()}

t()

@type t() :: %Karta.DANE{
  base: String.t(),
  records: [Karta.DANE.TLSA.t()],
  usable: [Karta.DANE.TLSA.t()]
}

Functions

lookup(target, port, dns \\ [])

@spec lookup(map(), :inet.port_number(), keyword()) :: result()

The TLSA records of target (a Karta.Outbound.MXResolver target) for delivery to port. dns are the options of Karta.DNS.lookup/3. See the module doc.

ssl_options(dane, opts \\ [])

@spec ssl_options(t(), keyword()) :: [:ssl.tls_client_option()]

:ssl client options that authenticate the server with the usable records of dane (RFC 7672 §3):

  • DANE-EE (usage 3): the server's own certificate (the first it sends) must match. Nothing else about it is checked: not its names, not its validity period (§3.1.1, §3.2.1). It may be self-signed.
  • DANE-TA (usage 2): another certificate of the chain the server sent must match. It becomes the only trust anchor: the server's certificate must chain to it (signatures, validity periods, constraints of the certificates below it) and be valid for the TLSA base domain or one of :names (§3.2.2; a wildcard stands for the first label only). As for any trust anchor, its own validity period is not checked (RFC 5280 §6.1).
  • Nothing else is trusted, not even the operating system's roots.

The server name sent (SNI) is the TLSA base domain (§8.1).

Options:

  • :names - reference identifiers besides the base domain: the recipient domain (§3.2.2).
  • :report - {pid, ref}: each problem found is sent to pid as {ref, :bad_cert, reason}, reason being :no_match when no record matches, otherwise as :ssl names it (:hostname_check_failed, :cert_expired, ...).
  • :enforce - false completes the handshake whatever the check found (for a policy that only reports). Default true.

text(dane)

@spec text(t()) :: String.t()

The RRset in presentation form, one record a line, for the policy-string of TLS reports (RFC 8460 §4.4).