【问题标题】:Jose.JWT.Encode gives Invalid algorithm specified ExceptionJose.JWT.Encode 给出 Invalid algorithm specified Exception
【发布时间】:2018-02-02 12:25:48
【问题描述】:

我有使用 .Net45 框架 我想要证书文件中的令牌。

var privateKey=new X509Certificate2("my-key.p12", "password", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet).PrivateKey as RSACryptoServiceProvider;
string token=Jose.JWT.Encode(payload, privateKey, JwsAlgorithm.RS256);

上面的代码给出了Invalid algorithm Exception..

但是当我迁移到 net4.6 的同时,它适用于以下代码。

var privateKey=new X509Certificate2("my-key.p12", "password").GetRSAPrivateKey();
string token=Jose.JWT.Encode(payload, privateKey, JwsAlgorithm.RS256);

您能对这个问题提出任何建议吗?

【问题讨论】:

    标签: c# c#-4.0 jwt json-web-token


    【解决方案1】:

    重新导入密钥将起作用。

    有多种解决方法,最简单的一种是重新导入密钥以获得有效的提供者实现。

    请参阅以下 URL 以获得进一步说明。

    https://github.com/dvsekhvalnov/jose-jwt#rsacryptoserviceprovider

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      • 2015-10-24
      • 2021-12-09
      • 2022-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多