Hello!
I have written a asmx web service in Visual Studio 2013.
The WS is connecting to a provider using HTTPS and X.509 for authentication.
I have tried connecting using "basicHttpBinding" and "basicHttpsBinding" (Web.config) but always gets the error below.
Error: System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority 'www2.skatteverket.se'. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at System.Net.HttpWebRequest.GetResponse() at ....
I have created a behaviour for the X.509 and a binding for the endpoint, see below.
<behaviors>
<endpointBehaviors>
<behavior name="NavetBehavior">
<clientCredentials>
<clientCertificate findValue="MyCert" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
...
<basicHttpsBinding>
<binding name="personpostXMLSoapBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpsBinding>
...
<client>
<endpoint address="https://www2.skatteverket.se/na/na_epersondata/services/personpostXML"
behaviorConfiguration="NavetBehavior" binding="basicHttpsBinding"
bindingConfiguration="personpostXMLSoapBinding" contract="webservice.NaPersonPostXMLWS"
name="personpostXML" />
</client>
What am I doing wrong?