I am implementing a c# webservice client that has to consume a Java webservice. Communication protocol is https and authentication has to be done via certificate (including private key).
As far as I know the purpose of the private key is to identify the correct customer database behind the webservice.
I don´t know the format of the certificate file because its file extension is "txt". If I try to import this file in the windows certificate store via mmc console an error occurs "file type could not be recognized" (I translated this from german, so it may sound a little bit different in english). So my client app can not use this certificate it would not find it in the certificate store.
I tried to instantiate the certificate and passing the file location into the constructor.
mVerifyCert = new X509Certificate2(AppConfig.Settings.Default.CertificateAndKeyFileFullName);
But then the following exception occurs (in english it might be "System.Security.Cryptography.CryptographicException: Object was not found."
{System.Security.Cryptography.CryptographicException: Das angeforderte Objekt wurde nicht gefunden.
bei System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) bei System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName) bei System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) bei System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName) bei System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName)
So now one might think there would be a problem with the file. But when this file is used with SoapUI Tool to test the webservice it works fine. I also hava java example client app the uses this file with java trust store and it works fine for the java client.
I have also tried to change the file extension from "txt" to "p12", "pem" in order to be able to import the file into windows certificate store but no success.
Can you tell me whats the problem here? What can I do to solve this. I have no clue at all.
Here is my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="QcsiSync.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<QcsiSync.Properties.Settings>
<setting name="DefactInstanceXmlFileNameFull" serializeAs="String">
<value>..\..\Data\getDefactInstance.xml</value>
</setting>
<setting name="DefactInstanceXmlDotNet" serializeAs="String">
<value>..\..\Data\DefactInstanceXmlDotNet.xml</value>
</setting>
<setting name="WebServiceUrl" serializeAs="String">
<value>https://xyz.com/wsAdapter</value>
</setting>
<setting name="CertificateFileFullName" serializeAs="String">
<value>..\..\Data\sdm.crt</value>
</setting>
<setting name="CertificateAndKeyFileFullName" serializeAs="String">
<value>..\..\Data\sdmCert + key.txt</value>
</setting>
<setting name="QcSupplierUrl" serializeAs="String">
<value>https://xyz.net/qcbin</value>
</setting>
<setting name="QcSupplierUsername" serializeAs="String">
<value>xyz</value>
</setting>
<setting name="QcSupplierPassword" serializeAs="String">
<value>xyz</value>
</setting>
<setting name="QcSupplierDomain" serializeAs="String">
<value>xyz</value>
</setting>
<setting name="QcSupplierProjetName" serializeAs="String">
<value>xyz</value>
</setting>
</QcsiSync.Properties.Settings>
</userSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSAdapterBFPortBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="WSAdapterBFPortBinding1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<!--<binding name="WSAdapterBFPortBinding2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>-->
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8890/wsAdapter" binding="basicHttpBinding"
bindingConfiguration="WSAdapterBFPortBinding" contract="QcsiWS.WSAdapterBCI"
name="WSAdapterBFPortHttp" />
<endpoint address="https://xyz.com/wsAdapter"
binding="basicHttpBinding" bindingConfiguration="WSAdapterBFPortBinding1"
contract="QcsiWebService.WSAdapterBCI" name="WSAdapterBFPortHttps" />
</client>
</system.serviceModel>
</configuration