SaltDns. Certificates. Renewal
(Salt v1.0.0)
When to renew, and how long to wait after a failure. Pure.
Timing
With renewal information from the provider (RFC 9773) the certificate is
renewed inside the suggested window: at a point of the window that is fixed
per certificate (a hash of its serial), so many certificates renewed at
the same moment do not all start together. A window already in the past
means "now". Renewal information older than ari_max_age (two days) is
not trusted.
Without it, a certificate is renewed when one third of its lifetime is left, and when one half is left for lifetimes of ten days or less.
Failures
After a failure the next try comes after 1, 10 and 100 minutes, then once a
day. After failures_per_provider (3) consecutive failures at one provider
the next provider of the certificate's list is used.
Guard
A bug must not burn a provider's rate limits: at most max_orders (5)
new orders per certificate in 24 hours.
Summary
Functions
The provider position after a failure: {index, provider_failures}. Moves
to the next provider (wrapping) when the current one failed enough times in
a row and there is another one.
True when renewal information was never asked or is older than ari_interval/0.
How often renewal information is asked: at least twice a day.
Minutes to wait after the failures-th consecutive failure (1-based).
Decides now: renew, or wait until a time.
Consecutive failures at one provider before the next one is tried.
Without renewal information: when the certificate is renewed.
Whether another order may be started, given the start times of the orders of the last 24 hours. When not, the time the oldest of them leaves the window.
The budget of new certificates per registered domain per week (default 30,
SALT_DNS_CERT_MAX_NEW_PER_DOMAIN_PER_WEEK): providers limit how many
certificates they issue per registered domain, which custom certificates make
reachable. Salt DNS has no public suffix list, so the domain is the least
specific zone of the organisation that contains the certificate's zone.
The order guard: how many new orders a certificate may start per day.
A fixed point inside the window, chosen by the serial.
The moment to renew: %{serial:, not_before:, not_after:, info:} where
info is renewal information or nil. Returns the time, not a decision.
True when the provider says to renew now: the window has started.
When to try again after the failures-th failure.
Types
@type decision() :: :renew_now | {:wait_until, DateTime.t()}
@type renewal_info() :: %{ window_start: DateTime.t(), window_end: DateTime.t(), checked_at: DateTime.t() } | nil
Functions
@spec after_failure(non_neg_integer(), non_neg_integer(), pos_integer()) :: {non_neg_integer(), non_neg_integer()}
The provider position after a failure: {index, provider_failures}. Moves
to the next provider (wrapping) when the current one failed enough times in
a row and there is another one.
@spec ari_due?(DateTime.t() | nil, DateTime.t()) :: boolean()
True when renewal information was never asked or is older than ari_interval/0.
@spec ari_interval() :: pos_integer()
How often renewal information is asked: at least twice a day.
@spec backoff_minutes(pos_integer()) :: pos_integer()
Minutes to wait after the failures-th consecutive failure (1-based).
@spec decide(map(), DateTime.t()) :: decision()
Decides now: renew, or wait until a time.
@spec failures_per_provider() :: pos_integer()
Consecutive failures at one provider before the next one is tried.
@spec fallback_time(DateTime.t(), DateTime.t()) :: DateTime.t()
Without renewal information: when the certificate is renewed.
@spec guard([DateTime.t()], DateTime.t(), pos_integer()) :: :ok | {:blocked, DateTime.t()}
Whether another order may be started, given the start times of the orders of the last 24 hours. When not, the time the oldest of them leaves the window.
@spec max_new_per_domain() :: pos_integer()
The budget of new certificates per registered domain per week (default 30,
SALT_DNS_CERT_MAX_NEW_PER_DOMAIN_PER_WEEK): providers limit how many
certificates they issue per registered domain, which custom certificates make
reachable. Salt DNS has no public suffix list, so the domain is the least
specific zone of the organisation that contains the certificate's zone.
@spec max_orders() :: pos_integer()
The order guard: how many new orders a certificate may start per day.
@spec pick_in_window(String.t(), DateTime.t(), DateTime.t()) :: DateTime.t()
A fixed point inside the window, chosen by the serial.
@spec renew_at(map(), DateTime.t()) :: DateTime.t()
The moment to renew: %{serial:, not_before:, not_after:, info:} where
info is renewal information or nil. Returns the time, not a decision.
@spec renew_now_advised?(renewal_info(), DateTime.t()) :: boolean()
True when the provider says to renew now: the window has started.
@spec retry_at(pos_integer(), DateTime.t()) :: DateTime.t()
When to try again after the failures-th failure.