DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:'htt

DNX Core 5.0 JwtSecurityTokenHandler quot;IDX10640: Algorithm is not supported: #39;http://www.w3.org/2001/04/xmldsig-more#hmac-sha256#39;quot;(DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:http://www.w3.org/2001/04/xmldsig-more
本文介绍了DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

I'm trying to implement JWT tokens but keep running into the following exception: IDX10640: Algorithm is not supported: 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' when trying to write the token to compact json string.

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);

有解决这个问题的想法吗?

Any ideas on solving this?

更新 1:

上述错误发生在 "System.IdentityModel.Tokens.Jwt": "5.0.0-beta7-208241120"

The error above occurs with "System.IdentityModel.Tokens.Jwt": "5.0.0-beta7-208241120"

更新 2:

更新代码

推荐答案

我们目前不支持对称密钥.希望能尽快实现.

We don't have support for symmetric keys right now. Hope to get that in soon.

这篇关于DNX Core 5.0 JwtSecurityTokenHandler“IDX10640:不支持算法:'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Custom Error Queue Name when using EasyNetQ for RabbitMQ?(使用 EasyNetQ for RabbitMQ 时自定义错误队列名称?)
How to generate password_hash for RabbitMQ Management HTTP API(如何为 RabbitMQ 管理 HTTP API 生成密码哈希)
Rabbitmq Ack or Nack, leaving messages on the queue(Rabbitmq Ack 或 Nack,将消息留在队列中)
Setup RabbitMQ consumer in ASP.NET Core application(在 ASP.NET Core 应用程序中设置 RabbitMQ 消费者)
Specify Publish timeouts in mass transit(指定公共交通中的发布超时)
RabbitMQ asynchronous support(RabbitMQ 异步支持)