Another try

This commit is contained in:
Reinier Criel 2025-11-27 13:25:53 -08:00
parent 0106767c35
commit 2810a87cd0
2 changed files with 10 additions and 13 deletions

View file

@ -168,7 +168,16 @@ function loadCa() {
}
const { privateKey, certificate } = generateCa();
fs.mkdirSync(certFolder, { recursive: true });
// Ensure directory exists before writing files
try {
fs.mkdirSync(certFolder, { recursive: true });
} catch (error) {
// Directory might already exist or there's a permission issue
if (/** @type {any} */(error).code !== 'EEXIST') {
throw error;
}
}
// Write files and ensure they're flushed to disk
const keyFd = fs.openSync(keyPath, 'w');