Internal PKI: offline root on hardware + per-purpose / per-cluster intermediates #9

Open
opened 2026-11-05 16:59:31 +00:00 by ginjiruu · 5 comments
Owner

Part of lab/machine-configs#7. Rewritten 2026-11-11, reasons in the dated comment below.

Framework

Mounts are named <purpose>[-<zone>]. The purposes are pki-infra, pki-issue, pki-cluster, pki-svc, and the SSH mounts owned by lab/machine-configs#19. The zone is fleet (omitted from the name), a cluster name, or an SSH zone. A mount name encodes purpose and trust zone, never a distribution name.

  • CA boundary equals DNS subzone equals auth mount. A zone-scoped issuing CA signs only names under its own DNS suffix, and that cluster's auth mount is the only path that can ask.
  • Depth budget, four levels max, root, purpose intermediate, zone CA, leaf.
  • Onboarding a cluster is pki-cluster-<c> plus pki-svc-<c> plus auth/kubernetes-<c>, with no new root ceremony.
  • The authoritative instance table lives in machine-configs docs/pki.md. lab/iac#47 imports against that file, not against this issue.

Shape

root CA                       P-384, 20 y, PIV 9c of the Nano, never enters OpenBao,
                              signs purpose intermediates only
├── pki-infra                 fleet plane, host + OpenBao + infra names under int.
│                             directly; lives in the trust store of every host
├── pki-issue                 pathlen 1, key inside OpenBao; signs the zone
│   └── pki-svc-<cluster>     workload CAs; cert-manager reaches it through
│                             auth/kubernetes-<cluster>; roles pinned to
│                             <cluster>.int.animeteamspeak.moe
└── pki-cluster-<cluster>     root-signed CA set for one cluster (server, client,
                              request-header, etcd peer/server, front-proxy, service),
                              minted before first boot, consumed by #11

ssh-user-<zone> / ssh-host-<zone>   lab/machine-configs#19; x509 never chains to these

pki-infra and auth/kubernetes-think are live. pki-cluster-think lands before the rebuild (#14). pki-svc-think and pki-svc-mini land when cert-manager moves to OpenBao issuers, replacing the per-cluster self-signed internal-root-ca the clusters mint today.

Facts

  • OpenBao's pki engine emits no RFC5280 name constraints. Zone enforcement is allowed_domains on roles, so a cross-zone refusal test is a role test.
  • The 2026-11-07 ceremony made pki-infra pathlen: 0, so it cannot sign sub-CAs. pki-issue is what takes the Nano out of cluster onboarding, one more ceremony run.
  • k3s, RKE2, and kubeadm all take pre-supplied CA sets at first boot. The CA set belongs to the cluster, the distribution is a detail. mini is RKE2 today.
  • Service names are <svc>.<ns>.svc.<cluster>.int.animeteamspeak.moe (lab/clusters#1671) and the recursor delegates think.int / mini.int as whole subzones (lab/clusters#1673). Bootstrap-critical names like openbao.int... are host-level, sit under int directly, and come from pki-infra.

Done when

  • Root generated offline on hardware, encrypted backups verified restorable (2026-11-07, Nano 33273351 slot 9c)
  • pki-infra intermediate issued, imported after init, OpenBao API TLS live, root in every host's trust store (scripts/pki-ceremony.sh, docs/day0-ceremony.md)
  • Next ceremony run issues pki-issue (pathlen 1)
  • pki-cluster-think minted with the full CA set and consumed by #11 at the #14 rebuild
  • pki-svc-think and pki-svc-mini live, cert-manager pointed at them through auth/kubernetes-<cluster>
  • A pki-svc-think role refuses a .mini.int name, proven, and a pki-svc-mini role signs there fine
  • Ceremony script covers pki-issue and pki-cluster-* (the human only moves the key between ports)
  • Instance table recorded in docs/pki.md

#11 (k3s consumes pki-cluster-think), #14 (rebuild), #19 + lab/iac#49 (SSH mounts), lab/clusters#1671 and #1673 (the DNS subzones this mirrors), lab/iac#47 (tofu imports this shape).

Part of lab/machine-configs#7. Rewritten 2026-11-11, reasons in the dated comment below. ## Framework Mounts are named `<purpose>[-<zone>]`. The purposes are `pki-infra`, `pki-issue`, `pki-cluster`, `pki-svc`, and the SSH mounts owned by lab/machine-configs#19. The zone is `fleet` (omitted from the name), a cluster name, or an SSH zone. A mount name encodes purpose and trust zone, never a distribution name. - CA boundary equals DNS subzone equals auth mount. A zone-scoped issuing CA signs only names under its own DNS suffix, and that cluster's auth mount is the only path that can ask. - Depth budget, four levels max, root, purpose intermediate, zone CA, leaf. - Onboarding a cluster is `pki-cluster-<c>` plus `pki-svc-<c>` plus `auth/kubernetes-<c>`, with no new root ceremony. - The authoritative instance table lives in machine-configs `docs/pki.md`. lab/iac#47 imports against that file, not against this issue. ## Shape ```text root CA P-384, 20 y, PIV 9c of the Nano, never enters OpenBao, signs purpose intermediates only ├── pki-infra fleet plane, host + OpenBao + infra names under int. │ directly; lives in the trust store of every host ├── pki-issue pathlen 1, key inside OpenBao; signs the zone │ └── pki-svc-<cluster> workload CAs; cert-manager reaches it through │ auth/kubernetes-<cluster>; roles pinned to │ <cluster>.int.animeteamspeak.moe └── pki-cluster-<cluster> root-signed CA set for one cluster (server, client, request-header, etcd peer/server, front-proxy, service), minted before first boot, consumed by #11 ssh-user-<zone> / ssh-host-<zone> lab/machine-configs#19; x509 never chains to these ``` `pki-infra` and `auth/kubernetes-think` are live. `pki-cluster-think` lands before the rebuild (#14). `pki-svc-think` and `pki-svc-mini` land when cert-manager moves to OpenBao issuers, replacing the per-cluster self-signed `internal-root-ca` the clusters mint today. ## Facts - OpenBao's pki engine emits no RFC5280 name constraints. Zone enforcement is `allowed_domains` on roles, so a cross-zone refusal test is a role test. - The 2026-11-07 ceremony made `pki-infra` `pathlen: 0`, so it cannot sign sub-CAs. `pki-issue` is what takes the Nano out of cluster onboarding, one more ceremony run. - k3s, RKE2, and kubeadm all take pre-supplied CA sets at first boot. The CA set belongs to the cluster, the distribution is a detail. mini is RKE2 today. - Service names are `<svc>.<ns>.svc.<cluster>.int.animeteamspeak.moe` (lab/clusters#1671) and the recursor delegates `think.int` / `mini.int` as whole subzones (lab/clusters#1673). Bootstrap-critical names like `openbao.int...` are host-level, sit under `int` directly, and come from `pki-infra`. ## Done when - [x] Root generated offline on hardware, encrypted backups verified restorable (2026-11-07, Nano 33273351 slot 9c) - [x] `pki-infra` intermediate issued, imported after init, OpenBao API TLS live, root in every host's trust store (`scripts/pki-ceremony.sh`, `docs/day0-ceremony.md`) - [ ] Next ceremony run issues `pki-issue` (pathlen 1) - [ ] `pki-cluster-think` minted with the full CA set and consumed by #11 at the #14 rebuild - [ ] `pki-svc-think` and `pki-svc-mini` live, cert-manager pointed at them through `auth/kubernetes-<cluster>` - [ ] A `pki-svc-think` role refuses a `.mini.int` name, proven, and a `pki-svc-mini` role signs there fine - [ ] Ceremony script covers `pki-issue` and `pki-cluster-*` (the human only moves the key between ports) - [ ] Instance table recorded in `docs/pki.md` ## Related #11 (k3s consumes `pki-cluster-think`), #14 (rebuild), #19 + lab/iac#49 (SSH mounts), lab/clusters#1671 and #1673 (the DNS subzones this mirrors), lab/iac#47 (tofu imports this shape).
Author
Owner

Decisions, 2026-11-07.

  • Root token: the owner's personal 5C Nano (33273351), PIV slot 9c, touch required on every use. PIV credentials set (management key PIN-protected).
  • mc#9 before OpenBao: the OpenBao API gets real TLS from day 0, not a throwaway bootstrap CA.
  • Chicken-and-egg resolved in the ceremony: pki-infra cannot be generated inside OpenBao before OpenBao exists, so the ceremony generates it (P-384, 5 years, pathlen 0), signs it with the root, and uses it to sign one API cert per think. It leaves the ceremony as an age-encrypted bundle and is imported into OpenBao's pki-infra mount right after bao operator init; then the bundle is deleted. The root still signs intermediates only.
  • API cert keys stay on the thinks: P-256 keys generated in /var/lib/openbao-tls/api.key (0400 root, done 2026-11-07), only CSRs left the hosts. SANs set by the ceremony: think-0N, think-0N.int.animeteamspeak.moe, openbao.int.animeteamspeak.moe, localhost, host IP, 127.0.0.1. One year.
  • pki-k3s-<cluster> and pki-services are generated inside OpenBao later; their CSRs get signed by the token over PKCS#11.

Script: scripts/pki-ceremony.sh <serial> <csr-dir> <out-dir> (main). DRY_RUN=1 tested: chains verify, both backups round-trip, /dev/shm clean on exit.

Decisions, 2026-11-07. - **Root token:** the owner's personal 5C Nano (33273351), PIV slot 9c, touch required on every use. PIV credentials set (management key PIN-protected). - **mc#9 before OpenBao:** the OpenBao API gets real TLS from day 0, not a throwaway bootstrap CA. - **Chicken-and-egg resolved in the ceremony:** `pki-infra` cannot be generated inside OpenBao before OpenBao exists, so the ceremony generates it (P-384, 5 years, pathlen 0), signs it with the root, and uses it to sign one API cert per think. It leaves the ceremony as an age-encrypted bundle and is imported into OpenBao's `pki-infra` mount right after `bao operator init`; then the bundle is deleted. The root still signs intermediates only. - **API cert keys stay on the thinks:** P-256 keys generated in `/var/lib/openbao-tls/api.key` (0400 root, done 2026-11-07), only CSRs left the hosts. SANs set by the ceremony: `think-0N`, `think-0N.int.animeteamspeak.moe`, `openbao.int.animeteamspeak.moe`, `localhost`, host IP, `127.0.0.1`. One year. - **`pki-k3s-<cluster>` and `pki-services`** are generated inside OpenBao later; their CSRs get signed by the token over PKCS#11. Script: `scripts/pki-ceremony.sh <serial> <csr-dir> <out-dir>` (main). `DRY_RUN=1` tested: chains verify, both backups round-trip, `/dev/shm` clean on exit.
Author
Owner

Why the body changed, 2026-11-11.

  1. pki-k3s-<cluster> welded a distribution name into the trust plane. mini runs RKE2 today, and the CA set k3s needs (server, client, request-header, etcd peer/server, front-proxy) is what any cluster needs. The unit is the cluster, so the mount is pki-cluster-<name>.
  2. One pki-services shared by every cluster puts a single issuing key over the whole int zone, where a role slip on one cluster could mint for another. Per-cluster workload CAs (pki-svc-<cluster>) make the CA boundary equal the cluster boundary, the same rule #19 states for SSH.
  3. "Name-constrained to int.animeteamspeak.moe" was fiction. OpenBao's pki engine emits no RFC5280 name constraints at all, enforcement is allowed_domains on roles. The done-when now tests what is really enforced, a cross-zone role refusal.
  4. Flat service names under int break wildcard routing, one *.int wildcard resolves to one IP and no cluster distinction. lab/clusters#1668/#1671/#1673 settled on <cluster>.int.animeteamspeak.moe subzones delegated at the recursor, so service CAs pin to those same subzones.
  5. The 2026-11-07 ceremony made pki-infra pathlen 0, so it cannot sign sub-CAs. The framework gains pki-issue (pathlen 1, key inside OpenBao) and one more ceremony run, which takes the Nano out of future cluster onboarding.
  6. Items already proven on 2026-11-07 (root on the Nano, pki-infra live, root in the fleet trust store) are marked done, so #12 and #13 no longer look blocked on them.
Why the body changed, 2026-11-11. 1. `pki-k3s-<cluster>` welded a distribution name into the trust plane. mini runs RKE2 today, and the CA set k3s needs (server, client, request-header, etcd peer/server, front-proxy) is what any cluster needs. The unit is the cluster, so the mount is `pki-cluster-<name>`. 2. One `pki-services` shared by every cluster puts a single issuing key over the whole `int` zone, where a role slip on one cluster could mint for another. Per-cluster workload CAs (`pki-svc-<cluster>`) make the CA boundary equal the cluster boundary, the same rule #19 states for SSH. 3. "Name-constrained to `int.animeteamspeak.moe`" was fiction. OpenBao's pki engine emits no RFC5280 name constraints at all, enforcement is `allowed_domains` on roles. The done-when now tests what is really enforced, a cross-zone role refusal. 4. Flat service names under `int` break wildcard routing, one `*.int` wildcard resolves to one IP and no cluster distinction. lab/clusters#1668/#1671/#1673 settled on `<cluster>.int.animeteamspeak.moe` subzones delegated at the recursor, so service CAs pin to those same subzones. 5. The 2026-11-07 ceremony made `pki-infra` pathlen 0, so it cannot sign sub-CAs. The framework gains `pki-issue` (pathlen 1, key inside OpenBao) and one more ceremony run, which takes the Nano out of future cluster onboarding. 6. Items already proven on 2026-11-07 (root on the Nano, `pki-infra` live, root in the fleet trust store) are marked done, so #12 and #13 no longer look blocked on them.
Author
Owner

Decision 2026-11-11: re-sign the root cert with the same Nano 9c key, pathlen UNSET.

Why: the 11-07 root carries pathlen:1 (scripts/pki-ceremony.sh:67). OpenSSL check with the same constraints: root -> CA -> leaf verifies; root -> pki-issue -> pki-svc- -> leaf fails with 'path length constraint exceeded' (error 25). So pki-issue cannot work under the current root cert.

Depth is enforced one level down instead: pki-infra 0 (as is), pki-issue 1, pki-svc- 0, pki-cluster- per-purpose CAs 0, root-signed directly (fits either way). Only the offline touch-gated root key can sign directly under the root, and each intermediate's own pathlen bounds anything below it, so an unset root pathlen widens nothing in practice and never needs another Nano session for depth.

Same key, subject and SKI: everything issued so far (pki-infra, think API certs) keeps validating. The new root.crt replaces machine-configs pki/root.crt, the flux trust-manager Bundle lab-root-ca, and think openbao-snapshot's copy.

Next ceremony run, one sitting: (1) root re-sign, (2) pki-issue from an OpenBao-generated CSR, (3) pki-cluster-think per-purpose CA set for k3s (#11).

Decision 2026-11-11: re-sign the root cert with the same Nano 9c key, pathlen UNSET. Why: the 11-07 root carries pathlen:1 (scripts/pki-ceremony.sh:67). OpenSSL check with the same constraints: root -> CA -> leaf verifies; root -> pki-issue -> pki-svc-<c> -> leaf fails with 'path length constraint exceeded' (error 25). So pki-issue cannot work under the current root cert. Depth is enforced one level down instead: pki-infra 0 (as is), pki-issue 1, pki-svc-<c> 0, pki-cluster-<c> per-purpose CAs 0, root-signed directly (fits either way). Only the offline touch-gated root key can sign directly under the root, and each intermediate's own pathlen bounds anything below it, so an unset root pathlen widens nothing in practice and never needs another Nano session for depth. Same key, subject and SKI: everything issued so far (pki-infra, think API certs) keeps validating. The new root.crt replaces machine-configs pki/root.crt, the flux trust-manager Bundle lab-root-ca, and think openbao-snapshot's copy. Next ceremony run, one sitting: (1) root re-sign, (2) pki-issue from an OpenBao-generated CSR, (3) pki-cluster-think per-purpose CA set for k3s (#11).
Author
Owner

Decisions and corrections, 2026-11-11 (second round).

Cluster CAs are signed by pki-issue, not the root. Every device trusts only the lab root either way, so the choice doesn't touch device trust. What it changes is the Nano: root-signed would mean a Nano session per new cluster. k3s keeps its CA keys on the server nodes anyway, so root-signing protected only the moment the CA was created. The "pki-cluster- root-signed" line in the body is superseded. pki-cluster- = per-purpose CAs signed by pki-issue, pathlen 0.

Correction to Facts: OpenBao does emit RFC 5280 name constraints. Tested on OpenBao 2.7.2 (dev server): sign-intermediate with permitted_dns_domains writes a critical Name Constraints extension. excluded_dns_domains and permitted_ip_ranges are accepted and silently dropped. So permitted DNS works, IP ranges and excludes do not. Zone CAs (pki-svc-, pki-cluster-) get constrained at signing. Role allowed_domains stays as the second layer.

Why it matters: devices trust everything below the root, including k3s CAs whose keys sit on nodes. With constraints, a stolen cluster CA key can't mint a cert any device accepts outside its names. Dry run: leaves for kubernetes.default.svc.think.int…, localhost, think-01 (plus IP SANs) verify; auth.animeteamspeak.moe, google.com and an unlisted node think-04 fail with "permitted subtree violation".

Scripts (5c7cfd5):

  • scripts/pki-ceremony-2.sh: root re-sign + pki-issue, 2 touches. Runbook docs/pki-ceremony-2.md.
  • scripts/pki-cluster-ca.sh <cluster>: no Nano. Constraint list in pki/clusters/<cluster>.domains.

k8s-hub: once a cluster's server CA chains to the lab root, its BackendTLSPolicy validates against the single lab-root-ca ConfigMap. The per-cluster k8s-hub-ca-* KV + ExternalSecret + Bundle chain retires cluster by cluster. Apiserver client trust stays per cluster (never the lab root: k8s maps any trusted client cert to a user).

Decisions and corrections, 2026-11-11 (second round). **Cluster CAs are signed by pki-issue, not the root.** Every device trusts only the lab root either way, so the choice doesn't touch device trust. What it changes is the Nano: root-signed would mean a Nano session per new cluster. k3s keeps its CA keys on the server nodes anyway, so root-signing protected only the moment the CA was created. The "pki-cluster-<cluster> root-signed" line in the body is superseded. pki-cluster-<c> = per-purpose CAs signed by pki-issue, pathlen 0. **Correction to Facts: OpenBao does emit RFC 5280 name constraints.** Tested on OpenBao 2.7.2 (dev server): `sign-intermediate` with `permitted_dns_domains` writes a critical Name Constraints extension. `excluded_dns_domains` and `permitted_ip_ranges` are accepted and silently dropped. So permitted DNS works, IP ranges and excludes do not. Zone CAs (pki-svc-<c>, pki-cluster-<c>) get constrained at signing. Role `allowed_domains` stays as the second layer. **Why it matters:** devices trust everything below the root, including k3s CAs whose keys sit on nodes. With constraints, a stolen cluster CA key can't mint a cert any device accepts outside its names. Dry run: leaves for `kubernetes.default.svc.think.int…`, `localhost`, `think-01` (plus IP SANs) verify; `auth.animeteamspeak.moe`, `google.com` and an unlisted node `think-04` fail with "permitted subtree violation". **Scripts (5c7cfd5):** - `scripts/pki-ceremony-2.sh`: root re-sign + pki-issue, 2 touches. Runbook `docs/pki-ceremony-2.md`. - `scripts/pki-cluster-ca.sh <cluster>`: no Nano. Constraint list in `pki/clusters/<cluster>.domains`. **k8s-hub:** once a cluster's server CA chains to the lab root, its BackendTLSPolicy validates against the single `lab-root-ca` ConfigMap. The per-cluster `k8s-hub-ca-*` KV + ExternalSecret + Bundle chain retires cluster by cluster. Apiserver client trust stays per cluster (never the lab root: k8s maps any trusted client cert to a user).
Author
Owner

Ceremony done 2026-11-11, after a broken first run. Full log in docs/pki-ceremony-2.md.

  • Run 1 (broken): the root re-sign rebuilt the subject from strings, so it came out PrintableString where the original is UTF8String. OpenSSL compares names loosely and every check passed. Go (bao CLI, OpenBao, tofu provider, snapshot agent) matches issuer bytes exactly and rejected OpenBao's API chain. Bridged by trusting both certs (flux), then replaced.
  • Run 2 (current): root 0D:97:06:B2:EF:90:2F:5A:FE:71:31:CA:DE:B9:68:91:9F:6E:71:10:76:F4:8D:B9:7D:1E:E8:E8:9F:5C:1B:BA. Same key, SKI and subject DER as the 11-07 cert, pathlen unset. The script copies rawSubject from pki/root-2026-11-07.crt, compares Name DER bytes, and verifies chains with Go (step certificate verify), including think-01's live API cert.
  • pki-issue: pathlen 1, valid to 2031-11-11, key generated in OpenBao. Default issuer pki-issue-2026 (iac #55, #56). Its chain ends at the run-2 root.
  • Rolled out, single cert everywhere: fleet (machine-configs 523362f, 7/7, no reboots; pi-02 trust store holds only the run-2 cert), mini lab-root-ca Bundle, think openbao-snapshot. Verified with Go: bao status, the snapshot job (uploaded), the openbao-config runner (NoDrift).

Done-when boxes now met: "Next ceremony run issues pki-issue (pathlen 1)" and "Ceremony script covers pki-issue". pki-cluster-* runs online through pki-issue (scripts/pki-cluster-ca.sh), no Nano needed.

Ceremony done 2026-11-11, after a broken first run. Full log in `docs/pki-ceremony-2.md`. - **Run 1 (broken):** the root re-sign rebuilt the subject from strings, so it came out PrintableString where the original is UTF8String. OpenSSL compares names loosely and every check passed. Go (bao CLI, OpenBao, tofu provider, snapshot agent) matches issuer bytes exactly and rejected OpenBao's API chain. Bridged by trusting both certs (flux), then replaced. - **Run 2 (current):** root `0D:97:06:B2:EF:90:2F:5A:FE:71:31:CA:DE:B9:68:91:9F:6E:71:10:76:F4:8D:B9:7D:1E:E8:E8:9F:5C:1B:BA`. Same key, SKI and subject DER as the 11-07 cert, pathlen unset. The script copies `rawSubject` from `pki/root-2026-11-07.crt`, compares Name DER bytes, and verifies chains with Go (`step certificate verify`), including think-01's live API cert. - **pki-issue:** pathlen 1, valid to 2031-11-11, key generated in OpenBao. Default issuer `pki-issue-2026` (iac #55, #56). Its chain ends at the run-2 root. - **Rolled out, single cert everywhere:** fleet (machine-configs 523362f, 7/7, no reboots; pi-02 trust store holds only the run-2 cert), mini `lab-root-ca` Bundle, think `openbao-snapshot`. Verified with Go: `bao status`, the snapshot job (uploaded), the openbao-config runner (NoDrift). Done-when boxes now met: "Next ceremony run issues pki-issue (pathlen 1)" and "Ceremony script covers pki-issue". pki-cluster-* runs online through pki-issue (`scripts/pki-cluster-ca.sh`), no Nano needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/machine-configs#9
No description provided.