SaltDns. Dnssec. Lifecycle
(Salt v1.0.0)
The lifecycle of DNSSEC for one zone, as a pure state machine.
It encodes the rule that keeps a zone from going bogus: the DS leaves the
parent first; only after every resolver cache has forgotten it is the zone
unsigned. (A resolver that still holds the DS expects signatures; an
unsigned zone then fails validation and returns SERVFAIL.) The machine does
no I/O. The caller (M8b) feeds it observations (Knot reports DNSKEY, a
validating resolver sees the parent's DS, a timer fires) and performs the
effects it returns (call SaltDns.Knot.set_dnssec/2, tell the user what to
do at the registrar).
States
:unsigned no DNSSEC
:signing switched on, waiting for Knot to publish DNSKEY
:signed_awaiting_ds signed; the parent has no DS yet (the zone is
"insecure" to resolvers until it does)
:signed_ds_published signed and the parent's DS has been seen
:ds_removal_pending switch-off requested; waiting until the parent no
longer has the DS (the user removes it at the registrar)
:ds_removed_waiting DS gone at the parent; waiting for caches to expire
:unsigning safe to unsign; Knot is being switched offwaiting_for/1 says what each state waits for. The only state from which
the zone may be unsigned is :unsigning, reached only through
:ds_removed_waiting and a :wait_elapsed event.
Events
{:enable, :nsec | :nsec3} user switches DNSSEC on
:dnskey_published Knot now publishes DNSKEY
{:parent_ds, :present | :absent} a validating-resolver check of the parent
{:change_mode, :nsec | :nsec3} change denial of existence while signed
:disable user starts the guided switch-off
:cancel_disable user changes their mind
:wait_elapsed the cache wait has passed
:unsigned Knot reports the zone unsignedEffects
{:set_dnssec, mode} call `SaltDns.Knot.set_dnssec/2`
:ksk_submitted call `SaltDns.Knot.ksk_submitted/1`
:show_ds show DS/CDS/CDNSKEY for the registrar
:instruct_remove_ds tell the user to remove the DS at the registrar
{:wait, seconds} start a timer; send `:wait_elapsed` when it fires
:cancel_wait stop that timer
Summary
Types
Timing inputs for the cache wait, in seconds: the parent's DS TTL, the parent zone's negative-caching TTL (its SOA minimum), and a safety margin.
Functions
The events that are allowed in state (with example arguments).
The state of a zone that has never been signed.
True only in the one state where unsigning the zone is safe.
True while the zone has DNSSEC records (anything but :unsigned).
All states.
Applies event in state. Returns the new state and the effects to
perform, or {:error, {:invalid_transition, state, event}}.
Seconds to wait after the parent's DS is seen to be gone: the longest a resolver may still hold the DS (its TTL), or the denial of its absence (the negative TTL), plus a margin. The longest of the TTLs that were observed is used.
What the state is waiting for, or nil for a resting state.
Types
@type context() :: %{ optional(:ds_ttl) => pos_integer(), optional(:negative_ttl) => pos_integer(), optional(:safety) => non_neg_integer() }
Timing inputs for the cache wait, in seconds: the parent's DS TTL, the parent zone's negative-caching TTL (its SOA minimum), and a safety margin.
@type ds_observation() :: :present | :absent
@type effect() :: {:set_dnssec, SaltDns.Knot.dnssec_mode()} | :ksk_submitted | :show_ds | :instruct_remove_ds | {:wait, pos_integer()} | :cancel_wait
@type event() :: {:enable, mode()} | :dnskey_published | {:parent_ds, ds_observation()} | {:change_mode, mode()} | :disable | :cancel_disable | :wait_elapsed | :unsigned
@type mode() :: :nsec | :nsec3
@type state() ::
:unsigned
| :signing
| :signed_awaiting_ds
| :signed_ds_published
| :ds_removal_pending
| :ds_removed_waiting
| :unsigning
Functions
The events that are allowed in state (with example arguments).
@spec initial() :: state()
The state of a zone that has never been signed.
True only in the one state where unsigning the zone is safe.
True while the zone has DNSSEC records (anything but :unsigned).
@spec states() :: [state()]
All states.
@spec transition(state(), event(), context()) :: {:ok, state(), [effect()]} | {:error, {:invalid_transition, state(), event()}}
Applies event in state. Returns the new state and the effects to
perform, or {:error, {:invalid_transition, state, event}}.
@spec wait_seconds(context()) :: pos_integer()
Seconds to wait after the parent's DS is seen to be gone: the longest a resolver may still hold the DS (its TTL), or the denial of its absence (the negative TTL), plus a margin. The longest of the TTLs that were observed is used.
When no TTL was ever observed (the zone was switched on and off before a DS was seen at the parent, or the parent never answered with one) there is no DS for a resolver to remember, except one published between two of our checks. The wait then is one hour (3600 seconds), which is longer than the interval between checks and far shorter than the day the parent's TTL could be; the margin is added as always. Before this, the wait was a full day plus the margin in that case.
@spec waiting_for(state()) :: nil | :dnskey_published | :parent_ds_present | :parent_ds_absent | :cache_expiry | :knot_unsigned
What the state is waiting for, or nil for a resting state.