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

  • Question

  • my code is:

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://192.168.1.6/api/genreport.htm?id=413&periodoffset=0&repstart=1899-12-30-00-00-00&repend=1899-12-30-00-00-00&login=admin&password=123456&noclean=1");


                 
                StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream());  
                string result = sr.ReadToEnd();  
                File.WriteAllText("c:\\Resulst.xml", result);

     

    here the error is:-

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

     

    please give me a solutio it urgent
    Tuesday, July 20, 2010 3:45 PM

Answers

  • if you want to request a https page,

    you have to use this...

    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    


    小中中的學習筆記
    • Marked as answer by awikrm Wednesday, July 21, 2010 8:35 AM
    Wednesday, July 21, 2010 3:31 AM