Appendix - Generating RSA256 Private and Public Key Pairs
jwt-authn
Generating RSA256 private and public key pair
with javascript
import crypto from "crypto";
const { publicKey, privateKey } = crypto.generateKeyPairSync(
"rsa",
{
modulusLength: 4096,
publicKeyEncoding: {
type: "spki",
format: "pem",
},
privateKeyEncoding: {
type: "pkcs8",
format: "pem",
cipher: "aes-256-cbc",
passphrase: "top secret", // this creates an encrypted private key. Make sure to pass it in when trying to sign a JWT. Omit for an unencrypted private key.
},
}
);
or from a bash shell
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key