SaltDns. Certificates. Issuer behaviour
(Salt v1.0.0)
The plug-in point for issuers. An issuer turns a request for the names of a
certificate into a signed chain. SaltDns.Certificates.Issuer.ACME is the
implementation Salt DNS ships; an issuer that does not speak ACME (a
company's own certificate authority) implements this behaviour and is
selected with config :salt_dns, SaltDns.Certificates, issuer: MyIssuer.
The behaviour is small on purpose. An order is started or resumed for a
set of names; it reports the DNS records it needs (Order.records, TXT
records for the DNS-01 challenge, or Order.http for HTTP-01: what the host must answer); once they are published the issuer is
told to respond; the order is polled until it is ready; it is finished
with a certificate signing request and the chain is fetched. Every call is
idempotent for the same order, so a job that restarts continues the same
order. renewal_info/2 asks the issuer when to renew (RFC 9773) or says it
cannot.
An order is identified by its ref, a JSON-compatible map the issuer makes
up and Salt DNS stores in Postgres.
Errors are {:error, {kind, message}} with kind one of :rate_limited,
:rejected (the issuer refused the names or the proof), :unavailable
(network or a server error: try again later), :invalid_order (the order
is dead; start another one) and :provider (anything else).
Summary
Callbacks
What the issuer's directory says it supports (see SaltDns.Certificates.Capabilities).
The certificate id used for replaces and renewal information, or nil if the issuer has none.
The issued chain as PEM, leaf first.
Finishes a ready order with a DER certificate signing request.
The order as the issuer sees it now.
Registers an account. Returns the account address and the serialised account key.
When to renew the certificate with this leaf (PEM), or :unsupported.
Tells the issuer the DNS records are in place and it may validate.
Reads an order again from its ref.
Starts an order for names. Options: :profile, :replaces (the
certificate id of the certificate this one replaces), :challenge ("dns-01",
the default, or "http-01": the order then reports Order.http and no
Order.records).
Types
@type window() :: %{ window_start: DateTime.t(), window_end: DateTime.t(), explanation_url: String.t() | nil }
Callbacks
What the issuer's directory says it supports (see SaltDns.Certificates.Capabilities).
@callback certificate_id(SaltDns.Certificates.Provider.t(), leaf_pem :: String.t()) :: String.t() | nil
The certificate id used for replaces and renewal information, or nil if the issuer has none.
@callback fetch(SaltDns.Certificates.Provider.t(), SaltDns.Certificates.Issuer.Order.t()) :: {:ok, pem :: String.t()} | error()
The issued chain as PEM, leaf first.
@callback finish( SaltDns.Certificates.Provider.t(), SaltDns.Certificates.Issuer.Order.t(), csr_der :: binary() ) :: {:ok, SaltDns.Certificates.Issuer.Order.t()} | error()
Finishes a ready order with a DER certificate signing request.
@callback poll(SaltDns.Certificates.Provider.t(), SaltDns.Certificates.Issuer.Order.t()) :: {:ok, SaltDns.Certificates.Issuer.Order.t()} | error()
The order as the issuer sees it now.
@callback register(SaltDns.Certificates.Provider.t()) :: {:ok, %{account_url: String.t(), account_key: binary()}} | error()
Registers an account. Returns the account address and the serialised account key.
@callback renewal_info(SaltDns.Certificates.Provider.t(), leaf_pem :: String.t()) :: {:ok, window()} | :unsupported | error()
When to renew the certificate with this leaf (PEM), or :unsupported.
@callback respond( SaltDns.Certificates.Provider.t(), SaltDns.Certificates.Issuer.Order.t() ) :: :ok | error()
Tells the issuer the DNS records are in place and it may validate.
@callback resume_order(SaltDns.Certificates.Provider.t(), map()) :: {:ok, SaltDns.Certificates.Issuer.Order.t()} | error()
Reads an order again from its ref.
@callback start_order(SaltDns.Certificates.Provider.t(), [String.t()], keyword()) :: {:ok, SaltDns.Certificates.Issuer.Order.t()} | error()
Starts an order for names. Options: :profile, :replaces (the
certificate id of the certificate this one replaces), :challenge ("dns-01",
the default, or "http-01": the order then reports Order.http and no
Order.records).
Functions
@spec impl() :: module()
The configured issuer module.