HttpClient ошибка The message received was unexpected or badly formatted
Не получается сделать запрос к сайту Личный кабинет ФССП. Подскажите в чем может быть проблема.
Мой код:
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br");
client.DefaultRequestHeaders.Add("Connection", "keep-alive");
client.DefaultRequestHeaders.Add("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7");
client.DefaultRequestHeaders.Add("Host", "lk.fssprus.ru");
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36");
var response = client.GetAsync("https://lk.fssprus.ru/ds_cabinet/action/login");
var httpResponseMessage = response.Result;
var content = httpResponseMessage.Content.ReadAsStringAsync();
Console.WriteLine(content.Result);
}
Console.ReadKey();
}
Вроде указал все, что советовали на форумах, но все равно ошибка:
System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (The SSL connection could not be established, see inner exception.) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task
1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at ConsoleApp5.Program.Main(String[] args) in C:\Projects\FsspConnectTest\ConsoleApp5\Program.cs:line 25Inner Exception 1: HttpRequestException: The SSL connection could not be established, see inner exception.
Inner Exception 2: AuthenticationException: Authentication failed, see inner exception.
Inner Exception 3: Win32Exception: The message received was unexpected or badly formatted.