switch to PKCS#8 key format for Bun compatibility

This commit is contained in:
2026-02-25 22:14:19 -06:00
parent 05bab2c90f
commit 49faf97c9b
4 changed files with 105 additions and 57 deletions
+9 -5
View File
@@ -1,9 +1,9 @@
import keypair from "keypair";
import crypto from "crypto";
console.log(`
Generating Private Keys
-----------------
This script will go through and genrate all the keys necessary for running the Credential Manager API locally.
This script will go through and generate all the keys necessary for running the Credential Manager API locally.
This process might take several minutes.
-----------------`);
@@ -42,9 +42,13 @@ await Promise.all(
if (!privExists || !pubExists) {
// Always regenerate both files together to ensure the key pair matches
console.log(`Generating '${v}' and '${pubPath}'...`);
const keys = keypair({ bits: 4096 });
await Bun.write(v, keys.private);
await Bun.write(pubPath, keys.public);
const { privateKey, publicKey } = crypto.generateKeyPairSync("rsa", {
modulusLength: 4096,
privateKeyEncoding: { type: "pkcs8", format: "pem" },
publicKeyEncoding: { type: "spki", format: "pem" },
});
await Bun.write(v, privateKey);
await Bun.write(pubPath, publicKey);
}
return;
}),