.NET 4.x The underlying connection was closed - C#
Формулировка задачи:
Добрый день. Подскажите начинающему. При выполнении следующего кода на Win XP:
возникает исключение: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
На Win 7 все нормально работает..
Подскажите как исправить. Заранее спасибо.
public void GetGMFromHtml()
{
try
{
string url = pathUpdate; //https://www.blabla.ru/bla.php
StringBuilder txt = new StringBuilder();
WebRequest req = WebRequest.Create(url);
WebResponse resp = req.GetResponse();
using (Stream stream = resp.GetResponseStream())
{
using (StreamReader sr = new StreamReader(stream))
{
txt.AppendLine(sr.ReadToEnd());
}
}
StreamWriter sw = new StreamWriter(@"update.txt", false, new UTF8Encoding(false));
sw.Write(txt);
sw.Close();
}
catch (Exception ex)
{
MessageBox.Show( ex.Message, "Ошибка обновления БД");
status = false;
return;
}
}Решение задачи: «.NET 4.x The underlying connection was closed»
textual
Листинг программы
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };