-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue on production. #1
Comments
@aqshah20
以上字符串第一个区块为签名秘钥,第二个区块为加密秘钥。你需要将这两个区块分别存储为相应的 生成以上字符串的代码如下:只需在terminal里运行 app.get("/gen-jwks", function (req, res) {
async function generateKey(){
let key = crypto.generateKeyPairSync('ec', {
namedCurve: 'prime256v1',
publicKeyEncoding: {
type: 'spki',
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
},
});
let cryptoKey = await jose.JWK.asKey(key.privateKey, 'pem');
console.log(cryptoKey.toPEM(true)); //!important
return cryptoKey;
}
async function generateJwks() {
//Creating Signing Key
let signingKey = await generateKey();
let publicSigningKeyJSON = signingKey.toJSON();
//Creating Encryption Key
let encryptionKey = await generateKey();
let publicEncryptionKeyJSON = encryptionKey.toJSON();
let jwks = {
keys: [{...publicSigningKeyJSON,
...{use: 'sig'},
...{crv: 'P-256'},
...{alg: 'ES256'},
},
{...publicEncryptionKeyJSON,
...{use: 'enc'},
...{crv: 'P-256'},
...{alg: 'ECDH-ES+A256KW'},
}]};
console.log(JSON.stringify(jwks));
}
generateJwks();
}); 注意
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to create pem format from json for the production? I have keys in json format.
The text was updated successfully, but these errors were encountered: