fix(mitm): generate root ca on server startup (#2228)
Direct MITM server startup read rootCA.key/.crt immediately and exited when either was missing, bypassing the manager.js CA setup path. - generate Root CA from server.js when key/cert is missing - make generateRootCA()/generateCert() synchronous to avoid a startup race before readFileSync - add unit test covering synchronous Root CA creation Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
parent
0b3c794075
commit
182c849979
@@ -7,8 +7,8 @@ const { generateRootCA, loadRootCA, generateLeafCert } = require("./rootCA");
|
||||
* Generate Root CA certificate (one-time setup)
|
||||
* This replaces the old static wildcard cert approach
|
||||
*/
|
||||
async function generateCert() {
|
||||
return await generateRootCA();
|
||||
function generateCert() {
|
||||
return generateRootCA();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ function isCertExpired(certPath) {
|
||||
* Generate Root CA certificate (only once, auto-regenerate if expired)
|
||||
* This Root CA will sign all dynamic leaf certificates
|
||||
*/
|
||||
async function generateRootCA() {
|
||||
function generateRootCA() {
|
||||
const exists = fs.existsSync(ROOT_CA_KEY_PATH) && fs.existsSync(ROOT_CA_CERT_PATH);
|
||||
if (exists && !isCertExpired(ROOT_CA_CERT_PATH)) {
|
||||
console.log("✅ Root CA already exists");
|
||||
|
||||
Reference in New Issue
Block a user