2

I have a tomcat webservice and a c# .net client that connects to the service. I created the Connection classes with wsdl.exe and everything is fine. But now i have activated ssl in tomcat to use https. In my c# app i only changed the url to https and i get the following error:

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

How do i avoid this message? is this because the cretificate is untrusted? How do i tell my client that this connection is trusted?

CubaLibre
  • 375
  • 1
  • 2
  • 14

1 Answers1

1

Yes, most likely the server's certificate isn't trusted for your client. You can handle the ServicePointManager.ServerCertificateValidationCallback to allow SSL connections to the invalid certificated servers:

private static bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
    return true; // allow connection despite any errors
}    
...
ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
Zruty
  • 8,377
  • 1
  • 25
  • 31