95 lines
4.8 KiB
Markdown
95 lines
4.8 KiB
Markdown
# 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": "<PEM PKCS#10>",
|
||
"profile": "intermediate",
|
||
"pub": "<one-time X25519 public key>",
|
||
"context": { "service": "ianitor", "host": "<server name>", "request_id": "<Ianitor pki request id>",
|
||
"csr_sha256": "<hex>" } }
|
||
```
|
||
|
||
Answer (sealed, handed out once): `{ "ok": true, "certificate": "<PEM>", "sha256": "<hex of the DER>" }`
|
||
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=<CN from the CSR>`; 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 <host> asks for a new Domi intermediate certificate, valid until <date>."
|
||
- 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`.
|