switch to PKCS#8 key format for Bun compatibility
This commit is contained in:
@@ -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;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user