Prabu Spark

Prabu Spark

  • NA
  • 124
  • 203.5k

could n't establish trust relationship for ssl/tls secure

Aug 16 2013 1:50 AM
Hi sir,
    I am getting the below error, while hosting the website in webserver.


"the underlying connection was closed. could not establish trust relationship for the ssl/tls secure channel".
I attached the code for your refernce. Kindly give me the solution for this problem.


public  string posted_data()
    {
string urls="http://www.mydomain.com?uname=hi&password=123";
        ASCIIEncoding encoding = new ASCIIEncoding();
        Stream newStream;
        string postData = "";
        postData += (urls);


        byte[] data = encoding.GetBytes(urls);

        // Prepare web request...
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(urls);

        myRequest.Method = "POST";
        myRequest.Accept = "text/plain";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = data.Length;
      newStream = myRequest.GetRequestStream();
        // Send the data.

        newStream.Write(data, 0, data.Length);
        // grab the response
        HttpWebResponse HttpWResp = (HttpWebResponse)myRequest.GetResponse();
        Stream streamResponse = HttpWResp.GetResponseStream();

        // And read it out
        StreamReader reader = new StreamReader(streamResponse);
        string response = reader.ReadToEnd();
        newStream.Close();
        return response;
    }

Answers (1)