未处理CryptographicException:系统找不到指定的文件 [英] CryptographicException was unhandled: System cannot find the specified file

查看:349
本文介绍了未处理CryptographicException:系统找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试拥抱SSL通信的奥秘,并在此网站。我正在尝试测试自己的证书。使用Visual Studio 2012,我仅添加了一个现有文件(我的证书为.pfx格式),然后在app.config中更改了证书和密码设置。但是,在尝试运行它时,出现错误:

I am trying to embrace the mysteries of SSL communication and have found a great tutorial on this site. I was trying to test my own certificate. Using Visual Studio 2012, I simply added an existing file (my certificate in .pfx format) and then changed the "certificate" and "password" settings in app.config. However, when trying to run it, I got an error:


CryptographicException未处理:系统找不到指定的文件

CryptographicException was unhandled: System cannot find the specified file

然后,我在Web Service中尝试了相同的操作。那里有关于该错误的更多详细信息:

Then, I tried the same in my Web Service. There I got some more details about the error:

System.Security.Cryptography.CryptographicException: System cannot find specified file.

   at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
   at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName)
   at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
   v System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
   v TestServer.DataService.LoadSoap() v c:\Users\Administrator\Documents\Visual Studio 2012\Projects\TestServer\TestServer\DataService.asmx.cs:line 48

我已经向文章作者写了这个问题,但是由于他的上次答复是在2012年3月,所以我不确定他是否会答复。如果有人可以帮助我解决这个问题,我将不胜感激。

I have written this question to the author of the article, but since his last reply was in March 2012, I am not sure, whether he will reply. If somebody could help me with this problem, I would be very grateful.

PS:将证书从.cer导出到.pfx时,我更改了文件已导出。尽管我怀疑它对问题的影响,但我还是会提及它。

P.S.: When exporting the certificate from .cer to .pfx, I have changed the title of the file exported. Although I doubt its effect on the problem, I'd rather mention it.

推荐答案

您是否在应用程序池中设置了以下内容在IIS中?

Did you set the following on the application pool in IIS?


  1. 转到IIS管理器

  2. 转到应用程序池实例

  3. 单击高级设置

  4. 在过程模型下,将加载用户配置文件设置为true

  1. Go to IIS Manager
  2. Go to the application pool instance
  3. Click advanced settings
  4. Under Process model, set Load User Profile to true

请参阅此堆栈问题以进一步阅读:设置IIS池的LoadUserProfile时会发生什么?

See this stack question for further reading: What exactly happens when I set LoadUserProfile of IIS pool?

这篇关于未处理CryptographicException:系统找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆