Answer the question
In order to leave comments, you need to log in
How to fix: Request was aborted: Failed to create SSL/TLS secure channel?
Error Messages:
System.Net.WebException: The request was aborted: Failed to create SSL/TLS secure channel. in System.Net.HttpWebRequest.GetResponse()
The code where the error occurs:
string html = string.Empty;
string url = "https://google.com";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
//навсякий пожарный добавил в решений этой ошибки видел подобое
request.Credentials = CredentialCache.DefaultCredentials;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
//Нашол решения что это строка должна помогать тут задаеться делегат возращающий true чтобы принимало любой сертификат
ServicePointManager.ServerCertificateValidationCallback += AcceptAllCertificatePolicy;
//просто делегат возращающий всегда true
public static bool AcceptAllCertificatePolicy(object sender, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question