Signs a licence file from an activation request. A licensing server
calls it, and mix aker.sign calls it on a developer's machine.
It signs only with the keys its caller hands it, held as
Aker.SigningKey. A host may ship it in every release, which is
safe: a host trusts only the root public keys it passes, so nobody
without a trusted root's private key makes a licence the host accepts.
Summary
Functions
The working key's certificate, signed by the root key: its public key,
:key_id, :not_before and :not_after.
The certificate pair in text, as encode_certificate/1 writes it, or
:error for anything else: over 2 KB, another shape, or a part a
licence file could not carry. It reads no signature, so issue/2
checks the pair against the root keys. A refusal prints nothing of
the input.
A certificate pair as one line of JSON: its two parts, base64. A
licensing server keeps this line in one secret, and
decode_certificate/1 reads it back.
The licence file for request_bytes, a request for opts[:product].
The licence file for fields, signed by working_key, carrying certificate.
A random UUID, version 4 (RFC 9562), as lowercase text.
Functions
@spec certificate(Aker.SigningKey.t(), Aker.SigningKey.t(), keyword()) :: %{ certificate: binary(), certificate_signature: binary() }
The working key's certificate, signed by the root key: its public key,
:key_id, :not_before and :not_after.
@spec decode_certificate(term()) :: {:ok, %{certificate: binary(), certificate_signature: binary()}} | :error
The certificate pair in text, as encode_certificate/1 writes it, or
:error for anything else: over 2 KB, another shape, or a part a
licence file could not carry. It reads no signature, so issue/2
checks the pair against the root keys. A refusal prints nothing of
the input.
A certificate pair as one line of JSON: its two parts, base64. A
licensing server keeps this line in one secret, and
decode_certificate/1 reads it back.
The licence file for request_bytes, a request for opts[:product].
It signs with :working_key (Aker.SigningKey), under one of two
certificates:
:certificateand:root_keys: a certificatemix aker.certifymade offline, asdecode_certificate/1reads it, and the root public keys (raw, 32 bytes) one of which must have signed it. A licensing server signs this way and never holds the root key. The key id comes from the certificate, and the term must end by the certificate'snot_after;:root_key: the root key signs a fresh certificate for the working key, asmix aker.signdoes on a developer's machine.
Both, or neither, answers {:error, {:invalid, :certificate}}, and so
does a certificate no key in :root_keys signed, one for another
working key, or one not in date now.
Other options: :customer, :seats, and the term as either
:term_days or :term_start plus :term_end (DateTime, UTC, start
before end); optionally :licence_id (1 to 64 bytes, default a new
UUID), :features ([]), :serial (1), :moves_per_term (20),
:key_id ("dev", or the certificate's) and :now.
It signs only a licence Aker.LicenceFile.verify/2 reads back, and
answers {:error, {:invalid, option}} for the first option outside the
reader's bounds, {:error, {:invalid, :term}} when both term forms are
given or the range is not a term, {:error, {:invalid, :term_end}} when
the term ends after the certificate, or {:error, {:invalid, :size}}
when the licence would be over the reader's 4 KB.
@spec sign(map(), Aker.SigningKey.t(), map()) :: binary()
The licence file for fields, signed by working_key, carrying certificate.
@spec uuid() :: String.t()
A random UUID, version 4 (RFC 9562), as lowercase text.