SaltDns.Certificates.Names (Salt v1.0.0)

The name rules. A certificate is one of two kinds:

  • for a zone (the default): exactly the zone and *.zone, so a customer's domain gets one certificate for the domain and everything directly below it;

  • custom: one host, at any depth inside a zone of the organisation, alone (host) or with the wildcard below it (host and *.host).

  • external: one host that lies in no zone of Salt, validated by HTTP-01 through a proxy group (SaltDns.Certificates.Http01). Never a wildcard: HTTP-01 cannot prove one.

A wildcard covers one level. The DNS-01 challenge of both names of a pair is answered at _acme-challenge.<host>.

Pure. Names are lower-case A-labels without a trailing dot, as SaltDns.Zones.Name produces them; normalise_host/1 accepts Unicode input.

Summary

Types

An rrset of the zone as judge_host/3 reads it: full owner name, type, rdata strings.

An active zone of the installation, with the organisation that owns it.

Functions

The names from host upward that lie strictly below the zone apex: the host itself and every parent up to (not including) the apex.

Where the DNS-01 challenge of a zone is answered.

The subject of the signing request for a certificate with these names.

Normalises the host of an external certificate. Like normalise_host/1, and a wildcard is refused with the reason: only DNS-01 can prove a wildcard, and Salt does not serve this host's DNS.

The two names of a zone's certificate, zone first.

The names of a custom certificate: the host, and *.host when wildcard?.

Judges the host of an external certificate against every active zone of the installation. organisation_id is the organisation, or a list of the organisations whose zones count as its own (itself and its direct children, SaltDns.Proxy.own_organisation_ids/1). Returns :ok when the host lies in none of them, or {:error, {reason, message}}

Judges a custom certificate's host against the records of its zone. Returns {:ok, warnings} or {:error, {reason, message}}

A sentence for an error.

The most specific zone (the longest name) that contains host, from a list of zone names, or nil.

Normalises the host of a custom certificate (Unicode input is accepted) and returns the A-label form that is stored and the Unicode form for display. Wildcards, underscores and empty labels are refused: only host names a certificate can carry.

The registered domain of a zone for the weekly budget of new certificates: the least specific of zone_names that contains zone (or the zone itself). Salt DNS has no public suffix list; an organisation's own zones are what it can tell apart.

Checks names against the zone: the same two names in any order and any case. Returns them in canonical order, or an error. Anything else (a single name, a host name below the zone, a second level wildcard, another zone's name) is refused.

Types

error()

@type error() :: :not_wildcard_pair | :bad_zone

rrset()

@type rrset() :: {String.t(), String.t(), [String.t()]}

An rrset of the zone as judge_host/3 reads it: full owner name, type, rdata strings.

zone_owner()

@type zone_owner() :: %{name: String.t(), organisation_id: integer()}

An active zone of the installation, with the organisation that owns it.

Functions

below_apex(host, zone)

@spec below_apex(String.t(), String.t()) :: [String.t()]

The names from host upward that lie strictly below the zone apex: the host itself and every parent up to (not including) the apex.

challenge_name(zone_name)

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

Where the DNS-01 challenge of a zone is answered.

csr_subject(names)

@spec csr_subject([String.t(), ...]) :: String.t()

The subject of the signing request for a certificate with these names.

The common name must be one of the names being ordered: a provider counts it as an identifier, and Let's Encrypt refuses a request whose common name is not in the order ("CSR does not specify same identifiers as Order"). It used to be the zone name, which is only among the names of a zone certificate, so every custom certificate was refused. The first name that is not a wildcard is used; a set of wildcards only uses the first name as it is.

external_host(input)

@spec external_host(term()) ::
  {:ok, %{host: String.t(), unicode: String.t()}} | {:error, String.t()}

Normalises the host of an external certificate. Like normalise_host/1, and a wildcard is refused with the reason: only DNS-01 can prove a wildcard, and Salt does not serve this host's DNS.

for_zone(zone_name)

@spec for_zone(String.t()) :: [String.t()]

The two names of a zone's certificate, zone first.

host_names(host, bool)

@spec host_names(String.t(), boolean()) :: [String.t()]

The names of a custom certificate: the host, and *.host when wildcard?.

judge_external(host, zones, organisation_id)

@spec judge_external(String.t(), [zone_owner()], integer() | [integer()]) ::
  :ok | {:error, {:inside_own_zone | :inside_other_zone, String.t()}}

Judges the host of an external certificate against every active zone of the installation. organisation_id is the organisation, or a list of the organisations whose zones count as its own (itself and its direct children, SaltDns.Proxy.own_organisation_ids/1). Returns :ok when the host lies in none of them, or {:error, {reason, message}}:

  • :inside_own_zone: the host is in a zone of this organisation, where the normal DNS certificate works and needs no group;
  • :inside_other_zone: the host is in a zone Salt serves for another organisation. It is refused so nobody can obtain a certificate for a name somebody else keeps in Salt. The message does not say whose zone it is.

judge_host(host, zone, rrsets)

@spec judge_host(String.t(), String.t(), [rrset()]) ::
  {:ok, [String.t()]} | {:error, {:delegated | :challenge_cname, String.t()}}

Judges a custom certificate's host against the records of its zone. Returns {:ok, warnings} or {:error, {reason, message}}:

  • :delegated: NS records at the host or at a name between it and the zone apex. The challenge would be answered by other servers;
  • :challenge_cname: a CNAME at _acme-challenge.<host>.

Warnings (the request is still allowed): a CNAME at the host itself, and CAA records at the host or any name between it and the apex, which a provider reads instead of Salt DNS's apex records.

message(atom)

@spec message(error()) :: String.t()

A sentence for an error.

most_specific_zone(host, zone_names)

@spec most_specific_zone(String.t(), [String.t()]) :: String.t() | nil

The most specific zone (the longest name) that contains host, from a list of zone names, or nil.

normalise_host(input)

@spec normalise_host(term()) ::
  {:ok, %{host: String.t(), unicode: String.t()}} | {:error, String.t()}

Normalises the host of a custom certificate (Unicode input is accepted) and returns the A-label form that is stored and the Unicode form for display. Wildcards, underscores and empty labels are refused: only host names a certificate can carry.

registered_domain(zone, zone_names)

@spec registered_domain(String.t(), [String.t()]) :: String.t()

The registered domain of a zone for the weekly budget of new certificates: the least specific of zone_names that contains zone (or the zone itself). Salt DNS has no public suffix list; an organisation's own zones are what it can tell apart.

validate(zone_name, names)

@spec validate(String.t(), [String.t()] | nil) ::
  {:ok, [String.t()]} | {:error, error()}

Checks names against the zone: the same two names in any order and any case. Returns them in canonical order, or an error. Anything else (a single name, a host name below the zone, a second level wildcard, another zone's name) is refused.