# Custos ticket: sign an X.509 CSR with the Domi PKI root after a match-code approval Status: **written, not filed** (ROADMAP §6 Phase 3, §8.6). Ianitor uses the manual offline step in [pki.md](pki.md) until this exists. ## Why ROADMAP §1.2: the Domi PKI root key lives offline in Custos; the intermediate on the server is renewed yearly "through a Custos match-code approval". Custos (desktop 0.8.0, CustosPublic v0.13.0) has no such operation today: - The `sign` op (docs/09_signing.md) signs only `minisign`, `manifest`, `authenticode` and `approval` payloads. A sign request against `domi-root` is refused on purpose (apps/desktop/src-tauri/src/signing.rs, test at line 595). - `domi-root` is the RSA-3072 Household Root for Authenticode. Issuing TLS intermediates from it would mix code signing and TLS trust; the Domi PKI needs its own root. - The only server-reachable path is the factor-service sign mailbox (`POST /api/sign/requests`, `GET /api/sign/requests/{id}`, docs/09_signing.md:42-51), which carries the existing kinds only. ## What Ianitor needs ### 1. A new key: `domi-pki-root` - ECDSA P-256 (what rcgen and every TLS client support; no RSA keygen in ring). - Self-signed CA certificate, about 10 years, `basicConstraints CA:TRUE, pathLenConstraint 1`, key usage `keyCertSign, cRLSign`, subject `CN=Domi PKI Root, O=Fabrica Domi`. - Created in Custos, or **imported once** from the file Ianitor's offline CLI made (`ianitor-control ca init`, see pki.md), after which that file is destroyed. - Like the other signing keys: in the vault body member `signing`, never an item, never revealed, copied, shared or exported. The public certificate is readable through the existing `certificate` op (`custos-provision pub domi-pki-root`). ### 2. A new sign kind: `x509_csr` Request through the existing sign mailbox (same token, same sealing to a one-time X25519 key, same audit entry): ```json { "op": "sign", "namespace": "domi", "key": "domi-pki-root", "kind": "x509_csr", "csr": "", "profile": "intermediate", "pub": "", "context": { "service": "ianitor", "host": "", "request_id": "", "csr_sha256": "" } } ``` Answer (sealed, handed out once): `{ "ok": true, "certificate": "", "sha256": "" }` or `{ "ok": false, "error": "refused | expired | out_of_scope | invalid | no_key | denied | locked" }`. Custos must **not** copy the CSR's extensions. It builds the certificate itself from the `intermediate` profile and takes only the subject public key and the subject CN from the CSR: | Field | Value | |:--|:--| | Subject | `CN=`; refused unless the CN starts with `Ianitor Domi Intermediate` | | Validity | now − 5 min to now + 365 days, never past the root's notAfter | | basicConstraints | critical, `CA:TRUE, pathLenConstraint 0` | | keyUsage | critical, `keyCertSign, cRLSign, digitalSignature` | | Serial | 16 random bytes | | Signature | ECDSA P-256 / SHA-256 | It verifies the CSR's own signature (proof of possession) and refuses anything else (`invalid`). ### 3. The approval card Same flow as release signing (docs/12_hands_off.md §7): a card on the PC, a push to paired phones, approve with Face ID; 10 minutes, then `expired`. The card shows: - "Ianitor on asks for a new Domi intermediate certificate, valid until ." - The **match code**: Ianitor's own code, so Mark compares one number on two screens. It is computed on both sides from the CSR, not from the one-time key: `SHA-256(CSR DER)`, first 3 bytes, each byte mod 100, as three two-digit groups (`47 19 83`). Ianitor shows it in the UI banner; Custos shows it on the card. (Custos's usual `match_code(pub)` would also work if Ianitor showed that one instead; either is fine, but it must be one code, the same on both screens.) - Test keys may auto-approve as today; `domi-pki-root` always asks. ### 4. Optional, later: device certificates ROADMAP §4 also says "Device cert: … Issue (approve in Custos)". The device certificate is signed on the server with the intermediate, so Custos only has to approve, not sign: a kind `approval` request with `context.kind = "domi_device_cert"`, `name`, `match_code`, answered with the existing signed approval JSON (`domi-approve`), which Ianitor verifies against the `domi-approve` public key before issuing. No new crypto in Custos. ## Done when - `custos-sign csr --key domi-pki-root --profile intermediate --csr req.pem` (and the mailbox equivalent) returns a certificate that `openssl verify -CAfile root.pem` accepts, with `pathlen:0`, after a match-code approval on the phone. - A CSR with another CN, a bad signature or a request for a CA without pathLen 0 is refused. - An `x509_csr` request against any other key is `out_of_scope`. ## T4 (2026-11-17): what Ianitor on any server needs from Custos Not filed; written for the Custos session that picks it up. Each item has a working stand-in in Ianitor today. 1. **A target kind for an HTTP API token** (`http-token`: `host`, `secret`), so the team vault can hold Ianitor's previews-only token and hand it to Fabrica per preview deployment through `target.request` (CustosPublic `docs/TEAM.md`, "Target credentials"). Stand-in: the `registry` kind (a token with a host), docs/previews.md. 2. **A generic team approval** (`approve.request`: a canonical statement, the request's match code on every member's card, an answer that carries the existing `custos team approval v1` statements and a proof `verify_proof` can check), so Ianitor can ask a teammate to approve an admin change (a new API token, a member, the engine switch, a renewal) without asking the team's release key to sign anything. Signing a dummy artifact with `sign.request` is not a stand-in: Ianitor would choose the digest the release key signs. Stand-in: admin changes need the admin role (crates/control/src/team.rs). 3. **A browser Domi key** (Fundamentum's web client): a WebCrypto key certified by the member's Tessera root, so a sign-in is a signed challenge, not a link. Stand-in: one-time setup and invite links that make a session cookie; members may record their Tessera root, and the team list shows its match code (`tessera match v1`, the same digits Custos shows).