WCF Client with both Basic and Client Certificate Authentication

713 Views Asked by At

I am trying to integrate with a Web Service end point which require Basic and Client Certificate for authentication using WCF. I tried below different setting based on suggestions online but still I am receiving "Could not establish secure channel for SSL/TLS with authority XXXXX". Server uses well known CA which is already available in Windows Certificate Store. In code I am adding ClientCredentials.UserName.UserName , ClientCredentials.UserName.Password & ClientCredentials.ClientCertificate.Certificate successfully.

1)

<security mode="TransportWithMessageCredential">
     <transport clientCredentialType="Basic"/>
 </security>

Result : "Could not establish secure channel for SSL/TLS with authority XXXXX"

2)

<security mode="TransportWithMessageCredential">
     <transport clientCredentialType="Basic" />
     <message clientCredentialType="Certificate" />
 </security>

Result : Result : "Could not establish secure channel for SSL/TLS with authority XXXXX"

3)

<security mode="Transport">
            <transport clientCredentialType="Certificate"/>
             <message clientCredentialType="UserName" />
  </security>

Result : The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="Realm"'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

How to attach the Client Certificate using Basic Authentication since the server is expecting Basic authentication based on error returned when setting clientCredentialType as "Certificate".

Note: Using SOAPUI I can successfully connect with server

1

There are 1 best solutions below

0
On

I replaced 2.0 Web Service Reference instead of a WCF Service Reference to send request with both Basic &Client Authentication and it worked as expected.

Note : Web Reference is old style deprecated model.