WCF Error : System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

After adding a new endpoint like TCP or Named Pipes when you try to run the application you get the below error

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

at System.ServiceModel.Description.ConfigLoader.LoadIdentity(IdentityElement element)

at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)

at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)

at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)

at System.ServiceModel.ServiceHostBase.ApplyConfiguration()

at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)

at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)

at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)

at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)

at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

 Check the app.config file the endpoint would be missing <dns > tag

Before : when the error occured

<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”

listenUriMode=”Explicit”>

<identity>

<certificateReference storeName=”My” storeLocation=”LocalMachine”

x509FindType=”FindBySubjectDistinguishedName” />

</identity>

</endpoint>

Corrected config file

<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”

listenUriMode=”Explicit”>

<identity>

<dns value=“localhost” />

<certificateReference storeName=”My” storeLocation=”LocalMachine”

x509FindType=”FindBySubjectDistinguishedName” />

</identity>

</endpoint>

Do this for all the end points. I have also heard removing the certificateReference¬† tag works but haven’t tried it.

Advertisements

3 thoughts on “WCF Error : System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s