Fares Ayyad
Fares Ayyad

Reputation: 415

Cannot find the X.509 certificate using the following search criteria Only when publishing the API

I'm trying to use webservice which in turn needs a certeficate

the certeficate is installed on local computer and my user account its' installed in my store(personal).

In development mode( visual studio ) i used the following code to link the cert:

string thumbprintVal = WebConfigurationManager.AppSettings["Thumbprint"];
                mPortType.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser,
                 StoreName.My, X509FindType.FindByThumbprint,
                thumbprintVal);

it's working fine in the development.

but when i publish the code to IIS it fails by giving this error:

Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'CurrentUser', FindType 'FindByThumbprint', FindValue 'Thumbprint value'."}

could anyone help with this?

Upvotes: 1

Views: 473

Answers (1)

Tomas Chabada
Tomas Chabada

Reputation: 3019

StoreLocation.CurrentUser may point to different store location for user that runs your IIS application. When you are running application in development mode, it runs as you so it has access to your certification store location.

Upvotes: 1

Related Questions