小编Zar*_*rof的帖子

如何创建使用 RsaSsaPssSha256 签名的 JWT

我正在尝试使用 RsaSsaPssSha256 签署 JWToken,并使用我从密钥库中读取的自签名 X509certificate2。

使用.net 4.61;

  1. 尝试使用Microsoft 的System.IdentityModel.Tokens.Jwt
SecurityTokenDescriptor tokenDescriptor = new SecurityTokenDescriptor
{
    Subject = ,
    SigningCredentials = new SigningCredentials(privateKey, SecurityAlgorithms.RsaSsaPssSha256Signature),  
    Expires = DateTime.UtcNow.AddMinutes(expirationMinutes),
};
Run Code Online (Sandbox Code Playgroud)

并得到以下错误:

"IDX10634: Unable to create the SignatureProvider.\nAlgorithm: 'PS256', SecurityKey: 'Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: 'xxxxxxxxxxxxxxxxxxxxxxxxxx', InternalId: 'xxxxx-xxxxxx-xxxx-xxxxxx'.'\n is not supported. The list of supported algorithms is available here: https://aka.ms/IdentityModel/supported-algorithms"
Run Code Online (Sandbox Code Playgroud)

不用说,SecurityAlgorithms.RsaSha256 按预期工作。

2.尝试使用Jose-JWT模块,得到如下错误:

"RsaUsingSha with PSS padding alg expects key to be of CngKey type."
Run Code Online (Sandbox Code Playgroud)


我在这里错过了什么?

c# jwt rsa-sha256

5
推荐指数
1
解决办法
401
查看次数

标签 统计

c# ×1

jwt ×1

rsa-sha256 ×1