我正在尝试掌握SSL通信的奥秘,并在这个网站上找到了一个很棒的教程。我想测试自己的证书。使用Visual Studio 2012,我只需添加现有文件(我的证书为.pfx格式),然后更改app.config中的“certificate”和“password”设置。但是,当我尝试运行它时,出现了错误:
CryptographicException was unhandled: System cannot find the specified file
接着,在我的Web服务中,我也尝试了同样的操作。那里我得到了更多关于错误的详细信息:
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月,所以我不确定他是否会回复。如果有人能帮助我解决这个问题,我将非常感激。
附言:在从 .cer 导出证书到 .pfx 时,我更改了导出文件的标题。虽然我怀疑它对问题的影响,但我还是想提一下。