Skip to content

Commit

Permalink
Avoiding creating RSACng on non-windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
fauna5 authored and slorello89 committed Nov 5, 2019
1 parent 568b570 commit 5ac6d62
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Nexmo.Api/PemParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,20 @@ public static RSA DecodeRSAPrivateKey(byte[] privkey, bool isPkcs8)
IQ = binr.ReadBytes(elems);

// ------- create RSACryptoServiceProvider instance and initialize with public key -----
#if NETSTANDARD1_6 || NETSTANDARD2_0
#if NET452
// TODO: throwing "Bad Data" exception even though RSACng is fine
var RSA = new RSACryptoServiceProvider();
#else
RSA RSA;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
RSA = new RSAOpenSsl();
RSA = new RSACryptoServiceProvider();
}
else
{
RSA = new RSACng();
}
#elif NET452
// TODO: throwing "Bad Data" exception even though RSACng is fine
var RSA = new RSACryptoServiceProvider();
#else
// 4.6+ introduced CNG
var RSA = new RSACng();
#endif
var RSAparams = new RSAParameters
{
Expand Down

0 comments on commit 5ac6d62

Please sign in to comment.