小编log*_*060的帖子

.Net Core 2.2容器上的jwt验证失败,出现401

在.net core 2.2中,当我对应用程序进行容器化时,出现Bearer错误=“ invalid_token”,error_description =“签名无效”

当我使用IIS / IIS Express在Windows上托管它时,它运行良好。

我的代码-令牌生成器是IBM API Connect,它使用RSA 256算法生成密钥

 var rsa = new RSACryptoServiceProvider();
 string exponentvalue = "AQAB";
 var e = Base64UrlEncoder.DecodeBytes(exponentvalue);
 var N = "public key  put your value here"
 var modulus = Base64UrlEncoder.DecodeBytes(N);
 rsa.ImportParameters(
     new RSAParameters()
     {
             Modulus = modulus,
             Exponent = e
    });
  var signingKey = new RsaSecurityKey(rsa);
Run Code Online (Sandbox Code Playgroud)
var tokenValidationParameters = new TokenValidationParameters
          {
              // The signing key must match!
              ValidateIssuerSigningKey = true,
              IssuerSigningKey = signingKey,

              // Validate the JWT Issuer (iss) claim …
Run Code Online (Sandbox Code Playgroud)

linux containers jwt docker .net-core

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

标签 统计

.net-core ×1

containers ×1

docker ×1

jwt ×1

linux ×1