我正在尝试将node-jose配置为使用来自目的地的jwks证书,但正在努力让node-jose使用该证书。 jwks证书如下所示:
{
"kid": "aaaa",
"kty": "RSA",
"alg": "RS384",
"exp": REDACTEDNUMBER10YEARSAWAY,
"n": "q_REDACTED",
"e": "AXXX",
"use" : "enc",
"x5c": ["MIIDAzREDACTED"]
},
这是我尝试设置node-jose并加密jwt(在异步函数中)的方式:
ks = await jose.JWK.asKeyStore([{
kid: "aaaa",
kty: "RSA",
alg: "RS384",
use: "enc",
n: "q_REDACTED",
e: "AXXX",
x5c: ["MIIDAzREDACTED"]
}]);
ejwt = await jose.JWE.createEncrypt(
{format: 'compact'},
{
key: ks.get("aaaa"),
header: {alg: "RS384", use: "enc" }
}
);
// createEncrypt doesn't resolve key.
将其用于密钥库可以工作:
ks = await jose.JWK.asKeyStore([{
kid: 'mykey',
kty: 'oct',
k: 'randomkey',
use: 'enc'
}]);
// works with createEncrypt using header: { alg: 'dir', use: 'enc' }