PKI: pki-net-caosh + routeros role; sim REST over verified HTTPS (#85) #88

Merged
ginjiruu merged 2 commits from routeros-pki into master 2026-11-14 20:42:58 +00:00
Owner

Closes #85

Production (vault root, applied by the tofu-controller on merge)

vault/pki-net.tf:

  • mount pki-net-caosh: key generated inside OpenBao, CSR signed online by pki-issue (no Nano), pathlen 0, DNS name constraint net.caosh.int.animeteamspeak.moe, 3 years
  • role routeros: subdomains of that zone plus IP SANs (management addresses), server auth only, EC P-256, 90-day TTL (Terraform renews ahead of expiry), 1-year max
  • policy pki-net-routeros-issue: update on pki-net-caosh/issue/routeros only, for the bench renderer and the routeros runner

tofu validate passes.

Merging applies it right away. openbao-config runs with approvePlan: "auto", so there's no plan gate. It only adds resources (one mount, its CA, one role, one policy) and changes nothing that already exists. The bootstrap runner AppRole may configure all of OpenBao (ADR-0003), so permissions are fine.

Rehearsed against the harness OpenBao (same 2.7.x) with this exact file, mount and policy renamed *-rehearsal:

  • apply created 6 resources, and the re-plan came back with no changes
  • a leaf for r9.net.caosh... + IP verifies against the (fake) root through the chain
  • common_name=evil.example.com is refused by the role
  • destroyed afterwards

The rehearsal caught one bug, fixed here: role TTLs as "2160h" drift forever because OpenBao stores seconds. They're now 7776000 / 31536000.

Sim (verified)

  • machine-configs scripts/harness-bao.sh builds the same mount, role and name constraint under the fake ceremony's pki-issue
  • scripts/lab-router-certs.sh issues r1/r2 certs from it and installs them right after boot. The leaf is imported alone as www-ssl, and the chain separately as lab-ca-1/2.
  • routeros/sim now uses https:// with ca_certificate = the lab root, never insecure

Results on a fresh lab:

  • curl --cacert <lab root> gives verify=0 / HTTP 200 on both routers
  • tofu apply over HTTPS created 228 resources, and plan -detailed-exitcode then returns 0
  • VRRP: r1 master and r2 backup on all 8 networks

Findings

  • Importing a PEM bundle names every cert in it the same, so www-ssl picked a CA without a key, which showed up as a handshake EOF. The leaf now goes in alone.
  • Any /certificate import inside an imported script makes RouterOS 7.25's REST /import answer {} instead of {"ret":"true"}, and containerlab then marks the node failed. In the lab the cert is pushed after boot. netinstall doesn't use REST, so the real bootstrap (#64) keeps the cert inside its .rsc.

Not in this PR

  • Day-2 renewal inside the router module (vault_pki_secret_backend_cert -> routeros_system_certificate -> www-ssl)
  • An AppRole for the routeros runner
  • DNS names for r1/r2 under net.caosh... (#50)
Closes #85 ## Production (vault root, applied by the tofu-controller on merge) `vault/pki-net.tf`: - mount `pki-net-caosh`: key generated inside OpenBao, CSR signed **online by `pki-issue`** (no Nano), pathlen 0, DNS name constraint `net.caosh.int.animeteamspeak.moe`, 3 years - role `routeros`: subdomains of that zone plus IP SANs (management addresses), server auth only, EC P-256, 90-day TTL (Terraform renews ahead of expiry), 1-year max - policy `pki-net-routeros-issue`: `update` on `pki-net-caosh/issue/routeros` only, for the bench renderer and the routeros runner `tofu validate` passes. **Merging applies it right away.** `openbao-config` runs with `approvePlan: "auto"`, so there's no plan gate. It only adds resources (one mount, its CA, one role, one policy) and changes nothing that already exists. The bootstrap runner AppRole may configure all of OpenBao (ADR-0003), so permissions are fine. **Rehearsed against the harness OpenBao (same 2.7.x)** with this exact file, mount and policy renamed `*-rehearsal`: - apply created 6 resources, and the re-plan came back with no changes - a leaf for `r9.net.caosh...` + IP verifies against the (fake) root through the chain - `common_name=evil.example.com` is refused by the role - destroyed afterwards The rehearsal caught one bug, fixed here: role TTLs as `"2160h"` drift forever because OpenBao stores seconds. They're now `7776000` / `31536000`. ## Sim (verified) - machine-configs `scripts/harness-bao.sh` builds the same mount, role and name constraint under the fake ceremony's `pki-issue` - `scripts/lab-router-certs.sh` issues r1/r2 certs from it and installs them right after boot. The leaf is imported alone as `www-ssl`, and the chain separately as `lab-ca-1/2`. - `routeros/sim` now uses `https://` with `ca_certificate` = the lab root, never `insecure` Results on a fresh lab: - `curl --cacert <lab root>` gives verify=0 / HTTP 200 on both routers - `tofu apply` over HTTPS created 228 resources, and `plan -detailed-exitcode` then returns 0 - VRRP: r1 master and r2 backup on all 8 networks ## Findings - Importing a PEM bundle names every cert in it the same, so `www-ssl` picked a CA without a key, which showed up as a handshake EOF. The leaf now goes in alone. - Any `/certificate import` inside an imported script makes RouterOS 7.25's REST `/import` answer `{}` instead of `{"ret":"true"}`, and containerlab then marks the node failed. In the lab the cert is pushed after boot. netinstall doesn't use REST, so the real bootstrap (#64) keeps the cert inside its `.rsc`. ## Not in this PR - Day-2 renewal inside the router module (`vault_pki_secret_backend_cert` -> `routeros_system_certificate` -> `www-ssl`) - An AppRole for the routeros runner - DNS names for `r1`/`r2` under `net.caosh...` (#50)
ginjiruu merged commit 5d92a2fcdd into master 2026-11-14 20:42:58 +00:00
ginjiruu deleted branch routeros-pki 2026-11-14 20:42:58 +00:00
Sign in to join this conversation.
No reviewers
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/iac!88
No description provided.