摘要:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
Question:
the 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.
Reply:
if you want to request a https page,you have to use this...
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };