小编Sud*_*han的帖子

JWT - 如何将 PrivateKey 传递给“SigningCredentials”以构建 SecurityTokenDescriptior?

我正在使用 c#.NET 创建 JWT 令牌。我有自己的 xml 私钥。我需要将其作为参数之一传递给函数signingCredentials。我的代码如下所示:

            var securityTokenDescriptor = new SecurityTokenDescriptor()
            {
                Subject = new ClaimsIdentity(List),
                Audience = "Audi",
                Issuer = "Issr",
                Expires = 5,
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Key), Microsoft.IdentityModel.Tokens.SecurityAlgorithms.HmacSha256Signature),
            };
Run Code Online (Sandbox Code Playgroud)

想知道如何传递 SigningCredentials 的私钥。

我有自己的私钥,作为标签 RSAKeyValue 之间的 xml 文件。

谢谢。

c# jwt

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

标签 统计

c# ×1

jwt ×1