SaltDns. Dnssec
(Salt v1.0.0)
DNSSEC for a zone as a user sees it: switch it on, give the registrar the
DS, switch it off safely. Postgres holds the intent and the lifecycle state
(SaltDns.Zones.Dnssec); Knot signs (SaltDns.Knot.Reconcile makes it
match the state); this module moves the state.
Who moves what
- The user asks (
request/3):{:enable, mode},{:change_mode, mode},:disable,:cancel_disable. The pureSaltDns.Dnssec.Lifecycledecides whether the request is allowed in the current state. Each accepted request is one audited, versioned change of the zone (actiondnssec.<name>), so the zone's writer picks it up like any other change. - The driver (
advance/2, run bySaltDns.Dnssec.Worker) looks at the world and feeds what it sees to the lifecycle: Knot publishing the DNSKEY (:signing->:signed_awaiting_ds), the parent's DS read from every authoritative server of the parent with recursion off (SaltDns.Resolver.ds/1, interpreted bySaltDns.Dnssec.Observe), the cache wait, Knot reporting the zone unsigned.
The order that keeps a zone from going bogus
Switching on: Knot signs; once the DNSKEY is published the user is shown the
DS; when every parent server has a DS that is one of ours, the KSK is
confirmed to Knot (ksk_submitted) and the zone is secure.
Switching off: the user is told to remove the DS at the registrar; the zone
keeps signing until every parent server has no DS at all; then it waits
the DS TTL seen earlier, the parent's negative TTL, and a margin
(SaltDns.Dnssec.Lifecycle.wait_seconds/1); then it checks the parent once
more and only if there is still no DS does it unsign (Knot is told :off
by the writer, which also removes the DNSSEC records). A DS that comes back
at any point restarts the wait. An inconclusive check never advances
anything, and ksk_submitted is called before a state is saved, so a failure
retries.
Settings: config :salt_dns, SaltDns.Dnssec, safety: 300 (seconds added to
the wait) and poll: [signing: 5, awaiting_ds: 60, published: 600, removal: 60, waiting: 60, unsigning: 5] (seconds between ticks).
Summary
Functions
Zones whose lifecycle is not at rest (anything but :unsigned), for the sweep.
One pass of the driver over a zone: observes what its state needs, feeds the
lifecycle, saves what changed. Moves through several states in one call when
the observations allow (for example :signing to :signed_awaiting_ds
to :signed_ds_published), at most six. Options: :now (a DateTime).
The requests that make sense now, for buttons and for the API.
The one thing to do next, as {code, plain text}.
Seconds until the driver should look at a zone in this state again, or nil.
The zone's keys as a registrar adapter takes them for set_dnssec/4
(%{flags:, protocol:, alg:, pub_key:}), read from the zone's CDNSKEY
records; [] while the zone is not signed. Salt's own signing is the
source: nothing is typed in by hand.
The user's request. Returns the zone with the new state, or
{:error, :invalid_transition} when the lifecycle does not allow it now.
Brings the zone to the wanted mode (:off, :nsec, :nsec3) by the
request the current state allows. Asking for what already holds is
accepted and changes nothing (so a PUT can be repeated). Returns
{:error, :invalid_transition} when the state does not allow the way
there (for example switching on while the switch-off is under way).
What the user needs to see: mode, state, what is awaited, the DS records for the registrar (from Knot, only while signed) and the next step.
Types
Functions
@spec active_zone_ids() :: [integer()]
Zones whose lifecycle is not at rest (anything but :unsigned), for the sweep.
@spec advance(integer() | SaltDns.Zones.Zone.t(), keyword()) :: {:ok, SaltDns.Zones.Zone.t() | nil, [SaltDns.Dnssec.Lifecycle.event()]}
One pass of the driver over a zone: observes what its state needs, feeds the
lifecycle, saves what changed. Moves through several states in one call when
the observations allow (for example :signing to :signed_awaiting_ds
to :signed_ds_published), at most six. Options: :now (a DateTime).
Returns {:ok, zone, [event]}; [] means nothing changed.
@spec allowed(SaltDns.Dnssec.Lifecycle.state()) :: [ :enable | :change_mode | :disable | :cancel_disable ]
The requests that make sense now, for buttons and for the API.
@spec next_step(SaltDns.Zones.Dnssec.t()) :: {atom(), String.t()}
The one thing to do next, as {code, plain text}.
@spec poll_seconds(SaltDns.Dnssec.Lifecycle.state()) :: pos_integer() | nil
Seconds until the driver should look at a zone in this state again, or nil.
@spec registrar_keys(SaltDns.Zones.Zone.t() | map()) :: [map()]
The zone's keys as a registrar adapter takes them for set_dnssec/4
(%{flags:, protocol:, alg:, pub_key:}), read from the zone's CDNSKEY
records; [] while the zone is not signed. Salt's own signing is the
source: nothing is typed in by hand.
@spec request(SaltDns.Zones.Zone.t(), request(), SaltDns.Zones.Actor.t()) :: {:ok, SaltDns.Zones.Zone.t()} | {:error, :invalid_transition | :not_found | :zone_frozen}
The user's request. Returns the zone with the new state, or
{:error, :invalid_transition} when the lifecycle does not allow it now.
@spec set_mode(SaltDns.Zones.Zone.t(), :off | :nsec | :nsec3, SaltDns.Zones.Actor.t()) :: {:ok, SaltDns.Zones.Zone.t()} | {:error, :invalid_transition | :not_found | :zone_frozen}
Brings the zone to the wanted mode (:off, :nsec, :nsec3) by the
request the current state allows. Asking for what already holds is
accepted and changes nothing (so a PUT can be repeated). Returns
{:error, :invalid_transition} when the state does not allow the way
there (for example switching on while the switch-off is under way).
@spec status(SaltDns.Zones.Zone.t()) :: map()
What the user needs to see: mode, state, what is awaited, the DS records for the registrar (from Knot, only while signed) and the next step.