Karta.MTASTS.Fetcher (Karta v1.0.0)

Fetches a domain's MTA-STS policy (RFC 8461 §3.3): GET https://mta-sts.<domain>/.well-known/mta-sts.txt.

  • Where. The policy host is resolved by Karta.NetGuard: private, loopback, link-local, carrier-grade NAT, unique local, NAT64, 6to4 and other special addresses are refused, and Karta connects to the checked address itself (no second lookup). The addresses are tried in order until one accepts the connection.
  • TLS. TLS 1.2 or 1.3; the certificate must chain to a trusted root (the operating system's, or :cacerts) and be valid for the policy host (RFC 6125, wildcards allowed); SNI names the host.
  • HTTP. HTTP/1.1 only. Only 200 counts; a redirect is not followed and nothing is cached by HTTP rules. The media type must be text/plain.
  • Limits. The whole fetch, every address and every read, must end within :timeout (default 60 s, RFC 8461's suggestion), and the body may be at most :max_size bytes (default 64 KiB); a larger body ends the fetch as soon as it is seen.

Errors carry the TLS-RPT result type (RFC 8460 §4.3.2.2) and a reason in words: {:error, :webpki_invalid, reason} when the policy host's certificate failed, {:error, :fetch_error, reason} for everything else.

Options: :port (default 443), :cacerts, :timeout, :max_size, and :dns, :allowed_networks, :blocked_networks for Karta.NetGuard.

Summary

Functions

Fetches the policy of domain (lower-case ASCII). See the module doc.

Types

error()

@type error() :: {:error, :fetch_error | :webpki_invalid, String.t()}

Functions

fetch(domain, opts \\ [])

@spec fetch(String.t(), keyword()) :: {:ok, binary()} | error()

Fetches the policy of domain (lower-case ASCII). See the module doc.