如何使用 RS256 算法为 JWT 生成私有证书和 public 证书?

How can I generate the private and public certificates for JWT with RS256 algorithm?

我想在 .NET 中使用 JWT 和 RS256 算法。

我用过图书馆 System.IdentityModel.Tokens.Jwt。本库支持RS256算法

如何在 Windows 上生成私有和 public 证书?

您可以通过安装和使用 Cygwin 软件包来生成它们:http://www.cygwin.com

使用以下命令:

1- 生成 私钥:

openssl genrsa -aes256 -out private_key.pem 2048

2- 生成 Public 密钥:

openssl rsa -pubout -in private_key.pem -out public_key.pem

您可以使用指定的库 (System.IdentityModel.Tokens.Jwt) 来生成您的断言 JWT。此处提供示例:https://vosseburchttechblog.azurewebsites.net/index.php/2015/09/19/generating-and-consuming-json-web-tokens-with-net/.