Error in WCF authorization using SSL

I am trying to use a service published by another company. Authorization and communication specifications:

  • SOAP
  • HTTPS with mutual SSL authorization (2-way SSL)
    • Use the public certificate they send us (I use as a ServiceCertificate)
    • Use the private certificate they created for us (I use as ClientCertificate)
  • WS-Security with UsernameToken

Here is the code I have provided so far:

WSHttpBinding binding = new WSHttpBinding(SecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
binding.SendTimeout = binding.CloseTimeout = binding.ReceiveTimeout = binding.OpenTimeout = new TimeSpan(0, 15, 0); // 15 minutes

Uri uri = new Uri(input.ServiceAddress);
EndpointAddress endpointAddress = new EndpointAddress(uri);

// Client creation
using (Client client = new Client(binding, endpointAddress))
{
    client.ClientCredentials.ClientCertificate.Certificate = input.PrivateCertificate;
    client.ClientCredentials.ServiceCertificate.DefaultCertificate = input.PublicCertificate;

    client.Open();

    // Service call
    ResponseType response = client.ServiceCall(params);
}

      

I am getting this error when calling the service:

An error occurred while accessing the HTTP request. This could be because the server certificate is not configured properly with HTTP.SYS in the case of HTTPS. It can also be caused by a security binding mismatch between client and server.

Things I've already tried:

  • Adding this line of code: "System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;"
  • Register public certificate on port with netsh
    • Using this command: "netsh http add sslcert ipport = 0.0.0.0: 443 certhash = Certificate thumbprint appid = {Application GUID}"
    • Based on another problem we had in another project

I don't know how to solve this problem and I don't understand about it! Have searched many times already and everything I've tried doesn't do it!

+3


source to share


1 answer


Found that our infrastructure has some network problems. Once we remove the security layer from my machine, the service will work.



I think the certificates (possibly keys) were not passing through the network and I was getting this error (because it was not authenticated).

0


source







All Articles