I'm trying to use a service publicated by another company. The specifications about the auth and communication are:
- SOAP
- HTTPS with mutual SSL auth (2-way SSL)
- Use a public certificate that they send us (I'm using as ServiceCertificate)
- Use a private certificate that they created to us (I'm using as ClientCertificate)
- WS-Security with UsernameToken
Here's the code I've come with until now:
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'm getting this error when the service is being called:
An error occurred while making the HTTP request to service. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
Things that I already tried:
- Adding this line of code: "System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;"
- Register the public certificate in the 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'm getting clueless about it! Already searched a lot and everything I try don't do it!