Cannot find the certificate in either the LocalMachine store or the CurrentUser store

☆樱花仙子☆ 提交于 2019-12-11 02:37:14

问题


I have already installed the ssl cert in user PC. And, I also imported the cert under Local computer of Trusted Root Certification Authorities. I am trying to consume the web servcie. In my code I attach the cert as below.

webservice.ClientCertificates.Add(X509Certificate.CreateFromCertFile(certPath));

But I got the following error.

Cannot find the certificate in either the LocalMachine store or the CurrentUser store

What could be the issue? I'm using .Net Framework 2.0. So, not able to use WCF. Thanks.


回答1:


That means,

  • probably you have the wrong certificates installed.
  • you installed the certificates to the wrong place.

An easy way to tell if you have a client certificate installed properly is

  1. launch IE.
  2. Open Tools | Internet options.
  3. In Content tab, click Certificates button.

Then you should see the cert in Personal (read cert path and see whether it contains errors), and will be able to use it in your WinForms application.




回答2:


I had the same error when trying to connect to a service that hadn't been set to use SSL. Once I change the configuration of the service to use SSL, the connection worked fine.

Also you may get that error if the account doesn't have access to the private key, which WinHttpCertCfg.exe from the Windows Resource Kit can solve.




回答3:


I experienced similar issue. In my case it was solved by using MMC and giving Full control rights of the certificate for user IIS_IUSRS. My Website is running under ApplicationPoolIdentity. This answer guided me to the right path: How to give ASP.NET access to a private key in a certificate in the certificate store?



来源:https://stackoverflow.com/questions/5048205/cannot-find-the-certificate-in-either-the-localmachine-store-or-the-currentuser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!