Search code examples
c#.nethttpssoap-clientweb-reference

How to make HTTPS SOAP request bypassing SSL certificate in .Net C#?


I had a problem trying to reach HTTPS web reference service in c# .Net project.

I got this message when i trying to send request to web service.

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

Then i found solution check the answer.


Solution

  • I put this code to my web service class constructor.

    ServicePointManager.ServerCertificateValidationCallback +=
                    (mender, certificate, chain, sslPolicyErrors) => true;
    

    It solves the problem.