System.Security.Cryptography.CryptographicException: The system cannot find the file specified<p> </p> <p>Hi,</p> <p> </p> <p>When i tried to use a third party web service  using IIS  , i am getting the following Error</p> <p><br><font face="Verdana, Geneva, Arial, Sans-serif"><b>Exception Details: </b>System.Security.Cryptography.CryptographicException: The system cannot find the file specified.</font></p> <p><br><font face="Verdana, Geneva, Arial, Sans-serif">[CryptographicException: The system cannot find the file specified.<br>]<br>   System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +1459868<br>   System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle&amp; safeProvHandle, SafeKeyHandle&amp; safeKeyHandle) +55<br>   System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +79<br>   System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(Boolean includePrivateParameters) +38<br>   System.Security.Cryptography.RSA.ToXmlString(Boolean includePrivateParameters) +41<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.a() +158<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.RequestLogin(String reasonMessage) +200<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.GetNewSecureSessionToken(Boolean attemptLogin) +148<br>   Globeranger.EdgeServices.Security.Runtime.Client.SecureInvoker.Invoke(ClientSession session, WebServicesClientProtocol service, String methodName, Boolean attemptLoginIfNeeded, Object[] args) +90<br>   Globeranger.EdgeServices.Security.Runtime.Client.SecureInvoker.Invoke(ClientSession session, WebServicesClientProtocol service, String methodName, Object[] args) +15<br>   Globeranger.EdgeServices.Ale.Runtime.Client.AleServerProxy.SendCommandEvent(String target, CommandEvent commandEvent) +216<br>   MidWareGlobeRanger.CommandEventSender.SendCommandEvent(String groupName, CommandEvent commandEvent) +40<br>   MidWareGlobeRanger.CommandEventSender.SendSuspendEvent(String groupName) +63<br>   RSC_Home.Page_Load(Object sender, EventArgs e) in c:\RSC_RFID_GUI\RSC_Home.aspx.cs:118<br>   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15<br>   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34<br>   System.Web.UI.Control.OnLoad(EventArgs e) +99<br>   System.Web.UI.Control.LoadRecursive() +47<br>   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061<br><br><br></font></p> <p>Any solution for this?</p> <p> </p> <p>Regards<br>Abraham</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 15 Oct 2009 08:51:29 Z7ea48fd0-8d6b-43ed-b272-1a0249ae490fhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#7ea48fd0-8d6b-43ed-b272-1a0249ae490fhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#7ea48fd0-8d6b-43ed-b272-1a0249ae490fabraham2http://social.msdn.microsoft.com/Profile/en-US/?user=abraham2System.Security.Cryptography.CryptographicException: The system cannot find the file specified<p> </p> <p>Hi,</p> <p> </p> <p>When i tried to use a third party web service  using IIS  , i am getting the following Error</p> <p><br><font face="Verdana, Geneva, Arial, Sans-serif"><b>Exception Details: </b>System.Security.Cryptography.CryptographicException: The system cannot find the file specified.</font></p> <p><br><font face="Verdana, Geneva, Arial, Sans-serif">[CryptographicException: The system cannot find the file specified.<br>]<br>   System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +1459868<br>   System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle&amp; safeProvHandle, SafeKeyHandle&amp; safeKeyHandle) +55<br>   System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +79<br>   System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(Boolean includePrivateParameters) +38<br>   System.Security.Cryptography.RSA.ToXmlString(Boolean includePrivateParameters) +41<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.a() +158<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.RequestLogin(String reasonMessage) +200<br>   Globeranger.EdgeServices.Security.Runtime.Client.ClientSession.GetNewSecureSessionToken(Boolean attemptLogin) +148<br>   Globeranger.EdgeServices.Security.Runtime.Client.SecureInvoker.Invoke(ClientSession session, WebServicesClientProtocol service, String methodName, Boolean attemptLoginIfNeeded, Object[] args) +90<br>   Globeranger.EdgeServices.Security.Runtime.Client.SecureInvoker.Invoke(ClientSession session, WebServicesClientProtocol service, String methodName, Object[] args) +15<br>   Globeranger.EdgeServices.Ale.Runtime.Client.AleServerProxy.SendCommandEvent(String target, CommandEvent commandEvent) +216<br>   MidWareGlobeRanger.CommandEventSender.SendCommandEvent(String groupName, CommandEvent commandEvent) +40<br>   MidWareGlobeRanger.CommandEventSender.SendSuspendEvent(String groupName) +63<br>   RSC_Home.Page_Load(Object sender, EventArgs e) in c:\RSC_RFID_GUI\RSC_Home.aspx.cs:118<br>   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15<br>   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34<br>   System.Web.UI.Control.OnLoad(EventArgs e) +99<br>   System.Web.UI.Control.LoadRecursive() +47<br>   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061<br><br><br></font></p> <p>Any solution for this?</p> <p> </p> <p>Regards<br>Abraham</p>Mon, 25 Jun 2007 09:35:41 Z2007-06-25T18:59:39Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#f3e1bac8-e357-40be-bfbc-46c641f413a6http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#f3e1bac8-e357-40be-bfbc-46c641f413a6ranamaurohttp://social.msdn.microsoft.com/Profile/en-US/?user=ranamauroSystem.Security.Cryptography.CryptographicException: The system cannot find the file specified<p>according to the documentation you would get this if &quot;The key cannot be exported&quot;:</p> <p><a title="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.exportparameters.aspx" href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.exportparameters.aspx">http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.exportparameters.aspx</a></p> <p> </p> <p>hopefully this helps, if not please send more details on what &quot;<font face=Verdana>Globeranger.EdgeServices.Security.Runtime.Client</font>&quot; is doing.</p>Mon, 25 Jun 2007 18:59:33 Z2007-06-25T18:59:39Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#adedf307-ad1c-4dae-92cc-9c2fa237b69ahttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#adedf307-ad1c-4dae-92cc-9c2fa237b69aabraham2http://social.msdn.microsoft.com/Profile/en-US/?user=abraham2System.Security.Cryptography.CryptographicException: The system cannot find the file specified<p><font color="#800000"><strong>Hi </strong><font color="#000000"> </font><a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=239670&amp;SiteID=1"><strong><u><font color="#0000ff">ranamauro</font></u></strong></a><strong>,</strong></font></p> <p><strong><font color="#800000"></font></strong> </p> <p><strong><font color="#800000"></font></strong> </p> <p><strong><font color="#800000">The problem occured due to some user priveledge issues in IIS , So i reconfigured IIS  and got it resolved .</font></strong></p> <p><strong><font color="#800000"></font></strong> </p> <p><font face=Verdana><strong>Globeranger.EdgeServices.Security.Runtime.Client is  third party component   that we are using to  access the web Methods .</strong></font></p> <p><strong><font color="#800000"></font></strong> </p> <p><strong><font color="#800000">Cheers</font></strong></p> <p><strong><font color="#800000">Abraham</font></strong></p> <p> </p>Tue, 26 Jun 2007 05:21:01 Z2007-06-26T05:21:01Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#98c46b8a-14d8-4a48-bfcd-c8fdbfb39331http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#98c46b8a-14d8-4a48-bfcd-c8fdbfb39331DLaffertyhttp://social.msdn.microsoft.com/Profile/en-US/?user=DLaffertySystem.Security.Cryptography.CryptographicException: The system cannot find the file specifiedYou wouldn't be able to elaborate on those IIS privilege settings?  I've a feeling that I'm running into a similar problem with IIS 7.0.<br><br>DL<br><br>Thu, 05 Jul 2007 08:54:46 Z2007-07-05T08:54:46Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#665b71f8-11f6-4a1b-9260-40c08fefe28fhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#665b71f8-11f6-4a1b-9260-40c08fefe28fLauraBhttp://social.msdn.microsoft.com/Profile/en-US/?user=LauraBSystem.Security.Cryptography.CryptographicException: The system cannot find the file specifiedHi, i ve got exactely the same exeption when i try my web site on my server. : <br><br><span id="_ctl0_MainContent_PostFlatView"><span><font face="Verdana, Geneva, Arial, Sans-serif">CryptographicException: The system cannot find the file specified.<br></font></span></span><span id=Label1>at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) at System.Security.Cryptography.RSA.FromXmlString(String xmlString) at Registration.EncryptAndSign(String strOriginalMessage, String KeySender, String KeyReciever) in c:\Inetpub\vhosts\uplay-istrip.com\httpdocs\upis\Registration.aspx.cs:line 175<br><br>When i try it on my PC with Visual Web Developer, it works fine...<br><br>So can u please tell me what did u change in your iss configuration? <br>It would be really helpful.<br>Thanx<br>Laura.<br></span>Fri, 06 Jul 2007 18:45:54 Z2007-07-06T18:45:54Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#06fc4033-61ad-44bb-9055-b230500a6c35http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#06fc4033-61ad-44bb-9055-b230500a6c35DLaffertyhttp://social.msdn.microsoft.com/Profile/en-US/?user=DLaffertySystem.Security.Cryptography.CryptographicException: The system cannot find the file specifiedHow I worked around the problem:<br><br>Under IIS 5.x/6.0, simply give the user running the ASP.NET process access to the machinekey store, or change to an interactive user.  I.e. one with Document and Settings folder with their desktop.<br><br>Under IIS 7.0, first, don't run using ASP.NET impersonation.  I.e. disable impersonation.  Second, follow suggestion for 5.x/6.0.<br>Mon, 09 Jul 2007 12:12:35 Z2007-07-09T12:12:35Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#37d4d83d-0eb3-497a-af31-030f5278781ahttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#37d4d83d-0eb3-497a-af31-030f5278781aLauraBhttp://social.msdn.microsoft.com/Profile/en-US/?user=LauraBSystem.Security.Cryptography.CryptographicException: The system cannot find the file specified<p>hi</p> <p>thanx for your answer.</p> <p>in fact, I ve found another solution. I don t really understand how, but it perfectly works : </p> <p>instead of writing :</p> <p><font color="#008080" size=2>RSACryptoServiceProvider </font>rsa = <font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>RSACryptoServiceProvider</font><font size=2>();</font></p> <p>i wrote :</p><font size=2> <p></font><font color="#008080" size=2>CspParameters</font><font size=2> CSPParam = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>CspParameters</font><font size=2>();</p> <p>CSPParam.Flags = </font><font color="#008080" size=2>CspProviderFlags</font><font size=2>.UseMachineKeyStore;</p> <p></font><font color="#008080" size=2>RSACryptoServiceProvider</font><font size=2> rsa;</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (System.Web.</font><font color="#008080" size=2>HttpContext</font><font size=2>.Current == </font><font color="#0000ff" size=2>null</font><font size=2>) </font><font color="#008000" size=2>// WinForm</p></font><font size=2> <p>rsa = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>RSACryptoServiceProvider</font><font size=2>();</p> <p></font><font color="#0000ff" size=2>else</font><font size=2> </font><font color="#008000" size=2>// WebForm - Uses Machine store for keys</p></font><font size=2> <p>rsa = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>RSACryptoServiceProvider</font><font size=2>(CSPParam);</font></p> <p><font size=2></font> </p> <p><font size=2>Hope it can help.</p> <p></font> </p>Mon, 09 Jul 2007 12:19:13 Z2007-07-09T12:19:13Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#ac70cc75-2e2f-4cf8-8ba9-414cad43446bhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#ac70cc75-2e2f-4cf8-8ba9-414cad43446bCezaryKhttp://social.msdn.microsoft.com/Profile/en-US/?user=CezaryKSystem.Security.Cryptography.CryptographicException: The system cannot find the file specifiedHello,<br>    In case you are working with the IIS 7, the solution for me was to change application pool's settings to load its identity profile. The command that does this is as follows:<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">appcmd set apppool &quot;AppPoolName&quot; -processModel.loadUserProfile:true </font></td></tr></tbody></table></div><br>    I had a problem with gaining access to certificate's private key under the account of the application pool in the context of a web service execution. The certificate was to be acquired from application pool's user personal certificate store.<br><br>Greetings,<br>Cezary<br> Tue, 01 Jul 2008 01:28:18 Z2008-07-01T01:28:18Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#8e6e7376-0a45-4d29-94ee-d77981d70c9ahttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#8e6e7376-0a45-4d29-94ee-d77981d70c9achanmathttp://social.msdn.microsoft.com/Profile/en-US/?user=chanmatSystem.Security.Cryptography.CryptographicException: The system cannot find the file specified<p>Hi,</p> <p>Thanks for LauraB's post.  However when I followed her posted answer it was not working for me when using <font color="#2b91af" size=2>DSACryptoServiceProvider.  <font color="#000000">I got this exception: <font size=1></p> <p>Exception information: <br>Exception type: CryptographicException <br>Exception message: Bad Version of provider.<br><br><font size=2>As a test, I tried specifying the KeyContainerName but another exception occurs: </font></p><font size=1> <p>Exception information: <br>Exception type: CryptographicException <br>Exception message: The specified cryptographic service provider (CSP) does not support this key algorithm.<br><br><font color="#2b91af" size=2><font color="#000000">Finally I specified the provider type code and it all works.  Complete Code is:</font></font></p><font size=2><font size=2> <p></font><font color="#008000" size=2>// Cryptograpy parameters<br>// Specify 13 for DSA procider type<br></font><font color="#2b91af" size=2>CspParameters</font><font size=2> CSPParam = </font><font color="#0000ff" size=2>new</font> <font color="#2b91af" size=2>CspParameters</font><font size=2>(13, </font><font color="#0000ff" size=2>null</font><font size=2>, </font><font color="#0000ff" size=2>null</font><font size=2>);<br>CSPParam.Flags = </font><font color="#2b91af" size=2>CspProviderFlags</font><font size=2>.UseMachineKeyStore;<br>CSPParam.KeyContainerName = &quot;Your Container Name&quot;;<br></font><font color="#2b91af" size=2>DSACryptoServiceProvider</font><font size=2> DSA;<br></font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#2b91af" size=2>HttpContext</font><font size=2>.Current == </font><font color="#0000ff" size=2>null</font><font size=2>) </font><font color="#008000" size=2>// WinForm<br></font><font size=2>{<br>    DSA = </font><font color="#0000ff" size=2>new</font> <font color="#2b91af" size=2>DSACryptoServiceProvider</font><font size=2>();<br>}<br></font><font color="#0000ff" size=2>else</font> <font color="#008000" size=2>// WebForm - Uses Machine store for keys<br></font><font size=2>{<br>    DSA = </font><font color="#0000ff" size=2>new</font> <font color="#2b91af" size=2>DSACryptoServiceProvider</font><font size=2>(CSPParam);<br></font><font size=2>}</font></p> <p><font size=2>Not sure why Microsoft don't have any info. on this, it took me some time to figure it all out.</font></p> <p><font size=2>Hope this help.</p></font></font></font></font></font></font>Mon, 10 Nov 2008 05:30:35 Z2008-11-10T05:30:35Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#aabfe4ef-4678-474f-a9ec-a8e39c7de660http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#aabfe4ef-4678-474f-a9ec-a8e39c7de660BradVoyhttp://social.msdn.microsoft.com/Profile/en-US/?user=BradVoySystem.Security.Cryptography.CryptographicException: The system cannot find the file specified<div class=quote><font class=quoteHeader>CezaryK said:</font> <p>Hello,<br>    In case you are working with the IIS 7, the solution for me was to change application pool's settings to load its identity profile. The command that does this is as follows:<br><br> <div style="font-size:11px;overflow:auto;line-height:100%! important;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255,255,255);border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">appcmd set apppool &quot;AppPoolName&quot; -processModel.loadUserProfile:true </font></td></tr></tbody></table></div><br>    I had a problem with gaining access to certificate's private key under the account of the application pool in the context of a web service execution. The certificate was to be acquired from application pool's user personal certificate store.<br><br>Greetings,<br>Cezary<br> <p></p></div><br><br>I just ran into this problem, and CezaryK's suggestion solved it for me.Wed, 18 Mar 2009 14:57:33 Z2009-03-18T14:57:33Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#bbdb7ffd-950b-41a8-8f89-db24e93dd496http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f#bbdb7ffd-950b-41a8-8f89-db24e93dd496max7khttp://social.msdn.microsoft.com/Profile/en-US/?user=max7kSystem.Security.Cryptography.CryptographicException: The system cannot find the file specifiedMy solution: <br /> change Application Pool to &quot;Classic .NET AppPool&quot; in IIS settings<br />Thu, 15 Oct 2009 08:51:28 Z2009-10-15T08:52:50Z