Cannot find the certificate in either the LocalMachine store or the CurrentUser store
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(X509Certific开发者_如何转开发ate.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.
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
- launch IE.
- Open Tools | Internet options.
- 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.
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?
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.
精彩评论