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

  • Question

  • I am able to send HTTP Post request using Google Chrome - PostMan client.

    But with below code:

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Timeout = 1200000;
                    byte[] bytes;
                    bytes = System.Text.Encoding.ASCII.GetBytes(jsonText);
                    request.ContentType = "application/json";
                    request.ContentLength = bytes.Length;
                    request.Method = "POST";
                    request.ClientCertificates.Add(cert);
                    Stream requestStream = request.GetRequestStream();
                    requestStream.Write(bytes, 0, bytes.Length);
                    requestStream.Close();
                    response = (HttpWebResponse)request.GetResponse();

    I am getting error as:

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

    What additional header do I need to include?

    Friday, July 13, 2018 6:56 AM

All replies

  • This is almost always an algorithm issue. Both sides support SSL but they cannot agree on the algorithm being used. Pretty much everybody is using TLS 1.2 these days. You need to ensure that your code is also using TLS 1.2. If this is an older app running on an older framework then you are likely targeting SSL 3/TLS 1.0 and so you cannot connect.

    https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, July 13, 2018 2:26 PM
    Moderator