TNA
TNA

Reputation: 616

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(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.

Upvotes: 3

Views: 26131

Answers (3)

jyrkim
jyrkim

Reputation: 2869

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?

enter image description here

Upvotes: 2

WhiteKnight
WhiteKnight

Reputation: 5056

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.

Upvotes: 1

Lex Li
Lex Li

Reputation: 63173

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.

Upvotes: 5

Related Questions