Skip to content

Commit 24a30a6

Browse files
committed
Fix error 'CspParameters' requires Windows Cryptographic API (CAPI), which is not available on this platform wich occurs loading private keys on Linux.
1 parent 98a3969 commit 24a30a6

File tree

1 file changed

+6
-1
lines changed
  • dotnet/src/extensions/SecurityAPI/dotnet/dotnetframework/SecurityAPICommons/Keys

1 file changed

+6
-1
lines changed

dotnet/src/extensions/SecurityAPI/dotnet/dotnetframework/SecurityAPICommons/Keys/PrivateKeyManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,14 @@ public AsymmetricAlgorithm getAsymmetricAlgorithm()
530530

531531
byte[] serializedPrivateBytes = this.privateKeyInfo.ToAsn1Object().GetDerEncoded();
532532
string serializedPrivate = Convert.ToBase64String(serializedPrivateBytes);
533+
533534
RsaPrivateCrtKeyParameters privateKey = (RsaPrivateCrtKeyParameters)PrivateKeyFactory.CreateKey(Convert.FromBase64String(serializedPrivate));
534535
#if NETCORE
535-
alg = DotNetUtilities.ToRSA(privateKey);
536+
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
537+
alg = rsa;
538+
byte[] serializedPrivateBytes1 = this.privateKeyInfo.ToAsn1Object().GetEncoded();
539+
int bytesread = 0;
540+
alg.ImportPkcs8PrivateKey(serializedPrivateBytes,out bytesread);
536541
#else
537542

538543

0 commit comments

Comments
 (0)