Karta. Outbound. TLSPolicy
(Karta v1.0.0)
The TLS a delivery to a domain must use (see Karta.Outbound.Transfer).
mode:
:opportunistic- encrypt when the server offers it, without checking its certificate;:verified- encrypt and check the server's certificate, or do not deliver;:testing- encrypt when offered and check the certificate, but deliver whatever the check says; failures are only reported;:encrypted- encrypt, or do not deliver, without checking the certificate (a server whose TLSA records are all unusable).
name is what a delivery attempt records as its policy, mta_sts the
domain's MTA-STS policy when one is in force (its MX patterns are
checked: enforced in enforce mode, reported in testing mode), dane
the TLSA records that decide for one MX host (for_host/2),
dane_required whether the configuration asks for DANE, and optional
whether the message says TLS-Required: No (below).
resolve/2 decides for a delivery, from the configuration and the
domain's MTA-STS policy (Karta.MTASTS), the strictest first:
- an MTA-STS policy in
enforcemode::verified, named"mta-sts", its MX patterns enforced; :verifiedin the configuration::verified, named"verified"(with an MTA-STS policy intestingmode, its MX patterns are reported);- an MTA-STS policy in
testingmode::testing, named"mta-sts-testing"; - otherwise
:opportunistic.
The configured mode is the default (:tls, normally :opportunistic)
unless :tls_policies names the domain:
config :karta, Karta.Outbound,
tls_policies: %{"bank.example" => :verified, "partner.example" => :dane}:dane asks for DANE (RFC 7672 §6): an MX host of the domain without
usable, validated TLSA records is not used.
DANE decides per MX host, before all of the above (for_host/2).
TLS-Required: No (RFC 8689 §3, §4.2.2; the :tls_optional
option): the sender asks that the recipient's policies not stop the
message. MTA-STS and DANE are then only reported: the policy is
:testing (STARTTLS when offered, the certificate checked by DANE or
against the trusted roots and the result reported, the message
delivered whatever it is, in clear when STARTTLS is missing or fails),
or :opportunistic without a policy, named "tls-required-no"; the MX
patterns of an enforce policy are only reported. The configuration
still applies: a domain configured :verified stays verified, and one
configured :dane still requires DANE.
REQUIRETLS (RFC 8689 §4.2.1): require_verified/1 raises a policy
to :verified.
Summary
Functions
The configured mode for domain under opts (:tls, :tls_policies).
The policy for one MX host, from the domain's policy and the host's
DANE lookup (Karta.DANE.lookup/3; RFC 7672 §2.2, RFC 8461 §2)
A policy of mode alone (:opportunistic or :verified), named after
it; a policy is returned unchanged.
The policy for a message that requires TLS (REQUIRETLS): a :verified
policy as it is; any other becomes :verified, named "requiretls",
the certificate checked against the trusted roots (TLSA records that
are all unusable do not authenticate).
The policy for a delivery to domain under the delivery options opts
(:tls, :tls_policies, :mta_sts, :dns; see
Karta.Outbound.Deliverer) and :tls_optional (the message says
TLS-Required: No). See the module doc.
Types
@type mode() :: :opportunistic | :verified | :testing | :encrypted
@type t() :: %Karta.Outbound.TLSPolicy{ dane: Karta.DANE.t() | nil, dane_required: boolean(), mode: mode(), mta_sts: Karta.MTASTS.Policy.t() | nil, name: String.t(), optional: boolean() }
Functions
The configured mode for domain under opts (:tls, :tls_policies).
@spec for_host(t(), Karta.DANE.result()) :: {:ok, t()} | {:refuse, {:dnssec, term()} | :dane_required}
The policy for one MX host, from the domain's policy and the host's
DANE lookup (Karta.DANE.lookup/3; RFC 7672 §2.2, RFC 8461 §2):
- usable TLSA records: DANE authenticates the server (
:verified, named"dane"); the domain's MTA-STS policy and the configured mode do not apply to this host; - TLSA records that are all unusable: TLS without authentication
(
:encrypted, named"dane"), unless the policy is:verifiedalready; - no TLSA records: the domain's policy;
- a failed lookup:
{:refuse, {:dnssec, reason}}, the host must not be used; and without usable records underdane_required:{:refuse, :dane_required}.
Under TLS-Required: No (and unless the configuration verifies or
requires DANE) usable records are only checked and reported
(:testing), and nothing refuses the host.
A policy of mode alone (:opportunistic or :verified), named after
it; a policy is returned unchanged.
The policy for a message that requires TLS (REQUIRETLS): a :verified
policy as it is; any other becomes :verified, named "requiretls",
the certificate checked against the trusted roots (TLSA records that
are all unusable do not authenticate).
The policy for a delivery to domain under the delivery options opts
(:tls, :tls_policies, :mta_sts, :dns; see
Karta.Outbound.Deliverer) and :tls_optional (the message says
TLS-Required: No). See the module doc.