Finds the MTA-STS policies (RFC 8461) of the domains Sovite delivers
to, when mta_sts.enabled is on. Sovite.Core.Delivery applies them.
policy/2 follows RFC 8461 §5.1 for a domain:
- It looks up the
_mta-sts.<domain>TXT record. - If its
idis the one of the policy cached in the database (mta_sts_policies) and that policy has not expired, the cached policy is used. - Otherwise the policy is fetched from
https://mta-sts.<domain>/.well-known/mta-sts.txtand cached for itsmax_age.
When the record is missing or the lookup or fetch fails, a cached policy that has not expired is still used, so an attacker who blocks DNS or HTTPS cannot turn a policy off. Without one the domain has no policy, and the failure is returned for TLS-RPT.
Concurrent requests for a domain share one lookup, and answers are remembered for a minute, so a burst of deliveries to one domain makes one DNS query.
Options
:repo- theSovite.Core.Reporeference. Required.:resolver- defaults toSovite.DNS.default_resolver/0.:fetch- options forSovite.TLS.MTASTS.fetch/2, such as:timeout.:name- the registered name.
Telemetry
[:sovite, :mta_sts, :fetched]-%{},%{domain, policy_id, mode}[:sovite, :mta_sts, :failed]-%{},%{domain, reason}: no policy could be fetched, and no cached one was used.
Summary
Types
The policy to apply, or nil, and why a policy that may exist could
not be found: a TLS-RPT result type (RFC 8460 §4.3.2.2) and a
description.
Functions
Returns the policy of domain. Policies with mode none are returned
as no policy.
Starts the policy cache.
Types
@type result() :: %{ policy: Sovite.TLS.MTASTS.Policy.t() | nil, failure: {:sts_policy_fetch_error | :sts_policy_invalid | :sts_webpki_invalid, String.t()} | nil }
The policy to apply, or nil, and why a policy that may exist could
not be found: a TLS-RPT result type (RFC 8460 §4.3.2.2) and a
description.
Functions
@spec policy(GenServer.server(), String.t(), timeout()) :: result()
Returns the policy of domain. Policies with mode none are returned
as no policy.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the policy cache.