3

We are facing issue specifically in Windows Server 2012 R2.

Below is our demo code:

rsa.ImportParameters(new RSAParameters
                         {
                             Exponent = new byte[] { 1, 0, 1 },
                             Modulus = OurModulus
                         });

Throws exception like:

Exception Source : mscorlib

Exception Type : CryptographicException

Exception Message : The parameter is incorrect.

Exception Stacktrace :

at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)

at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)

at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)

This snippet is working fine in Windows 7, Windows 8, Windows 10 but fails in Windows Server 2012 R2.

TylerH
  • 20,799
  • 66
  • 75
  • 101
CodeBond
  • 31
  • 4
  • The MSDN docs say the exception means that either the provider cannot be acquired (unlikely here based on the stacktrace), or a parameter field is missing. My guess is that you're hitting an issue caused by stronger security being active on server operating systems. Try using ExportParameters(false) on your various platforms to see whether you get noticeably different results. – Zastai Sep 15 '15 at 15:41
  • Does it work in any other server versions? – TylerH Jan 19 '23 at 22:17

0 Answers0