簡體   English   中英

如何創建使用RsaSsaPssSha256簽名的JWT

[英]How to create JWT signed with RsaSsaPssSha256

我正在嘗試使用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),
};

並得到以下錯誤:

"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"

不用說SecurityAlgorithms.RsaSha256正如預期的那樣工作。

2.試圖使用Jose-JWT模塊並出現以下錯誤:

"RsaUsingSha with PSS padding alg expects key to be of CngKey type."


我在這里失蹤了什么?

在從.NET 4.60升級到4.61時,這是使用RsaSsaPssSha256時所必需的,我刪除了System.IdentityModel.Tokens.Jwt包並重新安裝它們(即使它是相同的dll文件)。 現在一切都按預期工作了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM