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 'www.providers-site.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. What am I doing wrong? Would I benefit from using the wsHttpBinding instead?
<behaviors>
<endpointBehaviors>
<behavior name="CertBehaviour">
<clientCredentials>
<clientCertificate findValue="MyCertCN" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
...
<basicHttpsBinding>
<binding name="mySoapBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpsBinding>
...
<client>
<endpoint address="https://www.providers-site.se/na/na_epersondata/services/personpostXML"
behaviorConfiguration="CertBehaviour" binding="basicHttpsBinding"
bindingConfiguration="mySoapBinding" contract="webservice.NaPersonPostXMLWS"
name="personpostXML" />
</client>
I did run a trace. Thanks to Mike Cheel! See trace here.
Does this trace mean the certificate is not accepted by the remote host (provider)? (rows 67-71) (Since "AUTHENTICATE_REQUEST NOTIFICATION_CONTINUE" and "AnonymousAuthenticationModule" starts after certificate authentication.)
CertificateMappingAuthenticationModule NOTIFY_MODULE_START RequestNotifications AUTHENTICATE_REQUEST
AUTH_START Authentication MapCliCert
AUTH_END Authentication
CertificateMappingAuthenticationModule NOTIFY_MODULE_END RequestNotifications AUTHENTICATE_REQUEST NOTIFICATION_CONTINUE
AnonymousAuthenticationModule NOTIFY_MODULE_START RequestNotifications AUTHENTICATE_REQUEST