title: System.Security.Cryptography.CryptographicException: The system cannot find the file specified
body: <p>I got this exception from the deployment machine, which didn't happened in my development machine. This is a .net framework website.</p>
  
  <pre><code>System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
  
     at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
     at System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle&amp; hProv)
     at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
     at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle&amp; safeProvHandle, SafeKeyHandle&amp; safeKeyHandle)
     at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
     at Org.BouncyCastle.Security.DotNetUtilities.CreateRSAProvider(RSAParameters rp)
     at Box.V2.JWTAuth.BoxJWTAuth..ctor(IBoxConfig boxConfig)
  </code></pre>
  
  <p>My case is one of the SDK  used in the website is reading RSA private_keys.pem file. And looking into that SDK code in github:</p>
  
  <pre><code> var pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
          AsymmetricCipherKeyPair key;
          using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
          {
              key = (AsymmetricCipherKeyPair)new PemReader(reader, pwf).ReadObject();
          }
          var rsa = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)key.Private);
  </code></pre>
  
  <p>The SDK working fine in my development machine, but not the deployment machine. 
  I don't know what specified file cannot find, i think it is not the private_key.pem file. </p>
  
  <p>So I search around try to find out how the Cryptogrphy thing work out. 
  Here is what i found, point out anything if it wrong. 
  It seems like the cryptoAPI, create a RSA key container, and if application level don't have right access to the key container, it throw the exception. That is the specified file system looking for?</p>
  
  <p>If yes, how to fix it?</p>