Skip to content

fix(mitm): generate root ca on server startup#2228

Open
Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix/mitm-generate-root-ca-on-server-start
Open

fix(mitm): generate root ca on server startup#2228
Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix/mitm-generate-root-ca-on-server-start

Conversation

@Jordannst

Copy link
Copy Markdown
Contributor

Description

Fixes #2224.

Direct MITM server startup could fail before the Root CA was ever created because server.js read rootCA.key / rootCA.crt immediately and exited when either file was missing. That bypasses the manager.js setup path that normally generates the CA.

Changes

  • Generate the MITM Root CA from server.js when rootCA.key or rootCA.crt is missing.
  • Make generateRootCA() / generateCert() synchronous, matching their filesystem work and avoiding a startup race before readFileSync.
  • Add a targeted unit test proving Root CA files are created synchronously for direct server startup.

Verification

./node_modules/.bin/vitest run tests/unit/mitm-root-ca.test.js
node --check src/mitm/server.js && node --check src/mitm/cert/rootCA.js && node --check src/mitm/cert/generate.js
git diff --check

Also ran:

./node_modules/.bin/vitest run tests/unit/mitm-root-ca.test.js tests/unit/antigravity-mitm.test.js

The new MITM Root CA test passed. tests/unit/antigravity-mitm.test.js has an unrelated existing failure on the out-of-box Antigravity mandatory model assertion (expected undefined to be true).

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.

MITM cannot initialize on Windows because Root CA is never generated (rootCA.key missing)

1 participant