我正在尝试创建一个 JSON Web 密钥集以用于 node.js API 客户端。但是,在记录我的密钥时,它们似乎是空的。
const {JWKS} = require("jose");
const keyAlg = "RSA";
const keySize = 2048;
const keyUse = "sig";
const alg = "RS256";
const keystore = new JWKS.KeyStore();
keystore.generate(keyAlg, keySize, {
alg,
use: keyUse,
});
console.log("Public keys");
console.log("This can be used as the jwks in your API client configuration in the portal");
console.log(JSON.stringify(keystore.toJWKS(), null, 4));
console.log("Private keys");
console.log("This can be used as the keys value when configuring the api client");
console.log(JSON.stringify(keystore.toJWKS(true), null, 4));