简体   繁体   中英

Asp.net C# JWT Decode with private key (.p12)

I need to decode the encryptedToken with private key file .p12..

For private key, I already assign in X509Certificate2 and calling with

RSA privateKey = _x509private.GetRSAPrivateKey();

I am not using RSACryptoServiceProvider privateKey = _x509private.PublicKey.Key as RSACryptoServiceProvider; because that function is already deprecated.

But when I want to use this function to decode the encryptedToken string plainToken = Jose.JWT.Decode(encryptedToken, privateKey);

What I expected as output is token that I will verify token with public key. But, Unfortunately I get the error message of

Algorithm 'AesGcm' is not supported on this platform.

I was thinking the error message was arise because I didn't use RSACryptoServiceProvider as Private key.

I already search how to convert RSA to RSACryptoServiceProvider, but can't find anything...

I also considering not using the Jose.JWT.Decode() , but no luck...

Is there anyone that can help me?

PS: I am using .NET6 and Visual Studio Mac 2019 V.8

As bartonjs said in this comment , it only affects macOS.

.NET on macOS can't use Apple's AES-GCM implementation and requires OpenSSL to be installed to provide the algorithm. How to use .Net Core with Openssl3 on Mac OS? may help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM