Module cert_ledger
Expand description
Daemon-owned issued-certificate ledger.
The single canonical record of which device holds which client certificate
(device id + SHA-256 fingerprint + validity + status), the join key back to
the gateway pairing devices.db (token_hash), and the choke point that
writes the append-only certificate audit trail. The daemon owns the CA, so it
owns this ledger; when the gateway is present it READS the ledger (one store,
two readers - no third device store, per AGENTS.md no-duplicate-state).
Issuance is a two-phase commit across those two stores: the row lands in a
pending state that NO reader treats as a credential, and is promoted to
its final status only once the completion audit event is durable. A row this
ledger vouches for therefore always has a matching completion event, and
every failure mode - including a process that dies mid-issuance - leaves at
most a pending row, which the next open reconciles away
(CertLedger::record_issued).
Promotion happens BEFORE the certificate reaches its keyholder, so delivery
is tracked as a second, explicitly reconciled dimension: delivered_at, set
by CertLedger::mark_delivered at the real delivery/publication boundary
and swept by reconcile_undelivered_issuances at the first issuance, ledger
open, or explicit CertLedger::sweep_undelivered_certificates after the
TTL elapses (not on a timer - see that function for the residual). See
CertLedger::record_issued for why promotion-before-delivery is the
deliberately chosen failure direction.
Revocation is sourced here. The renew RPC (cert/renew) refuses a
revoked-but-unexpired cert immediately by consulting CertLedger::status_of
(threat A5). The WSS handshake-time refusal is wired separately against this
ledger via CertLedger::revoked_fingerprints / CertLedger::is_revoked.
Structs§
- Cert
Ledger - The daemon’s issued-certificate ledger over SQLite (
<data_dir>/tls/ledger.db). - Ledger
Entry - A row in the issued-cert ledger.
Enums§
- Cert
Status - Status of an issued certificate the ledger vouches for.
- Issuance
Actor - How an issuance was authorized; controls the audit
actorsemantics so the primary (self-service enrollment) path is never recorded with a blank actor.
Constants§
- ISSUANCE_
PRECONDITION_ FAILED - Marker carried in the error chain when an issuance is refused because its precondition no longer holds - a renewal whose certificate was revoked while the renewal was in flight.
Functions§
- effective_
revoked_ list_ path - The revoked-fingerprint list the WSS verifier will actually read: the
operator’s
[wss.client_auth].crl_pathwhen set, otherwise the ledger default under<data_dir>/tls/revoked. - revoked_
list_ path - The revoked-fingerprint list the daemon’s WSS mTLS verifier reads for connect-time revocation refusal (A5). The ledger materializes it on revoke.