Skip to content

feat(agent): add the fog-agent CA, CSR signing and the public CA files - #184

Merged
fog-workflows[bot] merged 1 commit into
masterfrom
feat/agent-pki
Nov 10, 2026
Merged

fog-workflows[bot] merged 1 commit into
masterfrom
feat/agent-pki

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

What

fog-node gets the fog-agent certificate authority, exactly as FOG 1.6 makes it, so one fog-agent binary can enroll against either server. This adds no agent route yet; the enroll PR uses it.

  • tools/setup/pki.js ensurePki(dir): root "FOG Server CA" and "FOG Agent CA" (RSA 4096, sha512, 10950 days, 1.6 subjects and extensions), agent-ca-bundle.pem. 1.6 regeneration rules: the certificate defines "exists"; a re-mint renames the old pair with a UTC timestamp. Keys are 0600 in a 0700 folder.
  • sails.helpers.agent.signCsr: leaf CN=fog-agent host <id>, O=FOG Project, OU=FOG Agent, 365 days, clientAuth, no SAN, chain = agent CA only. Checks proof of possession, then verifies the result.
  • sails.helpers.agent.keyFingerprint: sha256 of the public-key PEM text (the 1.6 / agent value, not the DER hash).
  • GET /management/other/ca.cert.pem, ca.cert.der, agent-ca-bundle.pem (public, as in 1.6).
  • npm run setup and setup:dev call ensurePki after writing config/local.js; a custom.pkiDir override is carried forward.
  • New dependency @peculiar/x509 1.14.3 (1.x is CommonJS). The lockfile diff is additions only.

Beyond 1.6: if root.pem is missing but root.key exists, the old key is renamed with a timestamp before a new root is made.

Verification

  • npm test: 242 passing. npm run test:install: all six checks pass.
  • With api/helpers/agent/ removed, the new tests fail (9 failing).
  • An openssl P-256 CSR with an empty subject (the agent's shape), signed by the helper: openssl verify -purpose sslclient -CAfile root.pem -untrusted agent-ca.pem leaf.pem → OK. The fingerprint equals openssl pkey -pubout | sha256sum.
  • Not checked locally: Node 22 (only 26 installed); CI covers it.

Reviews: spec (opus) clean; standards (opus) round-2 test duplication fixed.

🤖 Generated with Claude Code

fog-agent enrolls by sending a CSR and getting a client certificate signed
by the server's agent CA. This gives fog-node the same two CAs as FOG 1.6,
so one agent binary works against either server.

- tools/setup/pki.js: ensurePki(dir) makes the root (FOG Server CA) and the
  agent CA with the 1.6 parameters and regeneration rules, and the bundle.
  Setup and setup:dev call it after they write config/local.js.
- api/helpers/agent/sign-csr.js: signs a CSR as
  "CN=fog-agent host <id>, O=FOG Project, OU=FOG Agent", 365 days,
  clientAuth, chain = agent CA only, and verifies the result.
- api/helpers/agent/key-fingerprint.js: sha256 of the public-key PEM text.
- GET /management/other/ca.cert.pem, ca.cert.der, agent-ca-bundle.pem.
- @peculiar/x509 1.x (CommonJS) is the one new dependency.

Beyond 1.6: a missing root.pem with a root.key present renames the old key
with a timestamp before a new root is made, so a CA key is never lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 10, 2026 12:18
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into master with commit cd79930 Nov 10, 2026
6 checks passed
@fog-workflows
fog-workflows Bot deleted the feat/agent-pki branch November 10, 2026 12:34
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.

1 participant