How to fix: Could the SSL/TLS be secured?



  • System.Net.WebException: The request was interrupted: a secure SSL/TLS channel could not be established. in System.Net.HttpWebRequest.GetResponse()

    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();
    }



  • Try indicating the permitted protocols

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2