Skip to content

feat(certs): sign a device's own CSR, for mjolnir's card - #1723

Merged
Gerrrt merged 2 commits into
mainfrom
feat/mjolnir-card-ca-cert
Nov 24, 2026
Merged

Gerrrt merged 2 commits into
mainfrom
feat/mjolnir-card-ca-cert

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What changed

  • scripts/gen-certs.sh: new --csr <file>, used with --host. It signs a CSR made on another device and writes no key.
    • The CA sets the subject to /CN=<host>/O=matrix.elysium and the SANs from --ip/--dns. x509 -req copies no extensions from the request, so the device can't choose its own names.
    • It refuses a CSR whose self-signature doesn't verify, and refuses to overwrite an existing certificate without --force.
    • The normal key-generating path is unchanged.
  • docs/runbooks/generate-certificates.md: a new section, The APC card's leaf. It covers ssl csr -q on the card, signing, ssl cert -i, an openssl s_client -verify_return_error check, then switching the ups-ui probe to http_2xx_lab_ca.
  • docs/hardware.md: the card runs boot monitor 2.1.0.3, which the owner read on its About → Network page.
  • docs/changelog.md: entries for both.

Why

This was audit item 11: the card serves its factory self-signed certificate. The card can make a key and CSR and import a signed certificate from its CLI, so its key never needs to leave it. gen-certs.sh could only sign keys it generated itself.

Blast radius

The script change touches only the new flag's path. The card and the probe are unchanged until the runbook steps are run; the probe switch comes in a follow-up PR once the certificate is served.

Verification

  • bash -n and shellcheck are clean.
  • Tested against a throwaway CA:
    • --csr issues a certificate with our subject and SANs, ignores a SAN the CSR asked for, writes no key, and verifies against the CA.
    • A re-run without --force refuses, and so does a junk CSR or --csr without --host.
    • A normal leaf still issues with key mode 0640.
  • The card's current key is ECDSA P-256. An SSH handshake with just the two runbook overrides reaches the password prompt.
  • check_docs.py and lint.sh pass locally.

🤖 Generated with Claude Code

gen-certs.sh --csr <file> signs a certificate signing request made on
another device, so the key never leaves it. The CA sets the subject and
SANs, x509 -req copies no extensions from the request, and a request whose
self-signature fails is refused. generate-certificates.md gets the APC
card's steps: ssl csr -q on the card, sign, ssl cert -i, verify, then switch
the ups-ui probe to http_2xx_lab_ca. hardware.md records boot monitor
2.1.0.3, which the owner read on the card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The normal issuance path can overwrite an existing CSR-issued certificate without --force, replacing it with one whose key does not match the card and preventing import.

1 open issue
What changed in this PR

Adds device-generated CSR signing to the lab certificate workflow, enabling mjolnir’s APC card to use a lab-CA certificate without exporting its private key.

Changes:

  • Adds --csr support with request-signature validation, CA-controlled identities, and overwrite protection.
  • Documents card certificate issuance, import, verification, and the later probe cutover.
  • Records the card’s boot monitor version and the new signing workflow.
File Description
scripts/​gen-certs.sh Adds CSR signing without generating a local private key.
docs/​runbooks/​generate-certificates.md Adds APC certificate installation, verification, and recovery steps.
docs/​hardware.md Records boot monitor version 2.1.0.3.
docs/​changelog.md Records the version confirmation and CSR-signing support.

Review effort: Balanced

Comment thread scripts/gen-certs.sh Resolved
…ng path without --force

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt enabled auto-merge (squash) November 24, 2026 21:03
@Gerrrt
Gerrrt merged commit 1a462c9 into main Nov 24, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the feat/mjolnir-card-ca-cert branch November 24, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants