编程语言
首页 > 编程语言> > c# – DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:’http://www.w3.org/2001/04/xmldsig-more#hm

c# – DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:’http://www.w3.org/2001/04/xmldsig-more#hm

作者:互联网

我正在尝试实现JWT令牌,但仍然遇到以下异常:IDX10640:不支持算法:’http://www.w3.org/2001/04/xmldsig-more#hmac-sha256‘尝试将令牌写入压缩json字符串时.

const string issuer = "issuer";
const string audience = "audience";
byte[] keyForHmacSha256 = new byte[32];
new Random().NextBytes(keyForHmacSha256);

var claims = new List<Claim> { new Claim("deviceId", "12") };
var now = DateTime.UtcNow;
var expires = now.AddHours(1);
var signingCredentials = new SigningCredentials(
    new SymmetricSecurityKey(keyForHmacSha256), 
    SecurityAlgorithms.HmacSha256Signature, SecurityAlgorithms.Sha256Digest);

var token = new JwtSecurityToken(issuer, audience, claims, now, expires, signingCredentials);
return _tokenHandler.WriteToken(token);

解决这个问题的任何想法?

更新1:

“System.IdentityModel.Tokens.Jwt”出现上述错误:“5.0.0-beta7-208241120”

更新2:

更新的代码

解决方法:

我们现在不支持对称密钥.希望尽快得到它.

标签:json,c,jwt,adal
来源: https://codeday.me/bug/20190519/1136747.html