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).

Functions

The configured issuer module.

Types

error()

@type error() :: {:error, {kind :: atom(), message :: String.t()}}

window()

@type window() :: %{
  window_start: DateTime.t(),
  window_end: DateTime.t(),
  explanation_url: String.t() | nil
}

Callbacks

capabilities(directory_url)

@callback capabilities(directory_url :: String.t()) :: {:ok, map()} | error()

What the issuer's directory says it supports (see SaltDns.Certificates.Capabilities).

certificate_id(t, leaf_pem)

@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.

fetch(t, t)

The issued chain as PEM, leaf first.

finish(t, t, csr_der)

Finishes a ready order with a DER certificate signing request.

poll(t, t)

The order as the issuer sees it now.

register(t)

@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.

renewal_info(t, leaf_pem)

@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.

respond(t, t)

Tells the issuer the DNS records are in place and it may validate.

resume_order(t, map)

@callback resume_order(SaltDns.Certificates.Provider.t(), map()) ::
  {:ok, SaltDns.Certificates.Issuer.Order.t()} | error()

Reads an order again from its ref.

start_order(t, list, keyword)

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

impl()

@spec impl() :: module()

The configured issuer module.