如何使用ssh-keygen公钥和私钥对jwt令牌进行加密

时间:2019-01-20 12:44:10

标签: c# jwt public-key-encryption

我已经使用ssh-keygen创建了公钥和私钥

$ ssh-keygen -t rsa -b 4096 -f jwtRS256.key
$ openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub

尝试使用它:

//payload
var payload = new Dictionary<string, object>()
{
    { "sub", "mr.x@contoso.com" },
    { "exp", 1300819380 }
};

var key = File.ReadAllBytes(@"C:\Users\ravimodi\jwtRS256.key");
string token11 = Jose.JWT.Encode(payload, key, JweAlgorithm.RSA_OAEP, JweEncryption.A256GCM);

并得到错误:

  

RsaKeyManagement alg期望密钥为RSACryptoServiceProvider类型

0 个答案:

没有答案