Expand description
Cert issuance for /v1/enroll and /v1/agent/renew.
Structs§
- File
CaSigner - File-backed CA signer (current default; agenix-encrypted PEM on disk).
- TpmCa
Signer - TPM-backed CA. Holds uncompressed SEC1 P-256 pubkey (
0x04 || X || Y, 65 bytes - rcgen’s ECDSA shape) + thetpm-sign-<keyname>wrapper path. Issuer cert is self-signed via TPM once at construction; the real CA signature (by the offline fleet root) lives on disk and rcgen never reads it (only DN + pubkey), so the re-self-sign is sound. - TpmRemote
Signer 🔒 - Shells out to the keyslot’s
tpm-sign-<keyname>(file in, raw R||S out);der_encode_ecdsa_p256_sigrewraps to the DER form rcgen expects.
Enums§
- Audit
Context - Trust
Verify Error - Stage-typed error so axum handlers map each phase to the right StatusCode.
Constants§
- AGENT_
CERT_ VALIDITY - 30 days; agents self-pace renewal at 50% via
/v1/agent/renew. - DEFAULT_
AGENT_ CN_ SUFFIX - Example suffix for canonical agent CNs (
agent-<machineId>.<suffix>). Used as a stand-in byServerState::default()/ServeFlags::default()in tests; NOT a production fallback. Production gets the suffix from--agent-cn-suffixvia clap, which is a required argument with no default - the binary refuses to start if it’s unset.
Traits§
- CaSigner
- CA signer abstraction over file-backed + TPM-backed paths.
issuer()caches the cert at construction;make_key_pair()produces a fresh signer per issuance so operator key rotations apply without restart.
Functions§
- audit_
log - Best-effort append; write failure warns but doesn’t fail issuance.
- build_
signer_ from_ args - Builds a
CaSignerfrom a flag triple. TPM (pub_raw + wrapper) wins over file (fleet_ca_key); both absent ->None(enroll/renew will 500). - canonical_
agent_ cn - Build the canonical CN for an agent cert:
agent-<machineId>.<suffix>. - der_
encode_ 🔒ecdsa_ p256_ sig - Convert raw
R || S(64 bytes for P-256) to DEREcdsa-Sig-Value SEQUENCE { r INTEGER, s INTEGER }- what rcgen expects from aRemoteKeyPair::signfor ECDSA P-256. - der_
encode_ 🔒int - Big-endian unsigned int -> DER INTEGER. Strips leading zeros + pads if MSB set.
- extract_
machine_ id - Idempotent: passes through bare CNs unchanged, strips canonical wrapper.
- extract_
private_ key_ pem_ block - Extract the first private-key PEM block. Strips OpenSSL preambles
(
EC PARAMETERS) that rcgen’sKeyPair::from_pemcan’t read. - fingerprint
- Base64(SHA-256(bytes)).
- invoke_
tpm_ 🔒sign - Write
msgto a tempfile, invoke the tpm-sign wrapper, return stdout. - issue_
cert - Issues an agent cert: clientAuth EKU + canonical CN
agent-<machineId>.<suffix> - validate_
csr_ against_ fleet_ host - Bind agent identity to the host’s declared SSH host pubkey. Fail-closed:
no
pubkeyin fleet.nix ⇒ enrollment refused (declarative-enrollment policy, no permissive fallback). - validate_
token_ claims - Validates expiry, hostname-vs-CN, and pubkey fingerprint; caller verifies signature/replay.
- verify_
bootstrap_ token_ against_ trust - Re-reads trust.json per call (key rotations apply without restart).
ed25519-only.
nowenables thesuccessoroverlap window. - verify_
token_ signature - Cryptographic signature only; caller handles replay/hostname/fingerprint/expiry.