It is required to perform a simple GET request to the site using the HTTPS protocol, even if it is not valid. Here is an example site .

Host = "https://www.christopherleeco.com"; ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Host); request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string StausCode = response.StatusCode.ToString(); Stream resStream = response.GetResponseStream(); StreamReader readerStream = new StreamReader(resStream); string responseStream = readerStream.ReadToEnd(); 

I get an exception: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. . Although if instead of this "host" insert https://www.google.com , the request is normal.

  • Port checked? - Artyom
  • @artyom "https: //" and that means port 443, if you do so Host = "https://www.christopherleeco.com:443"; then nothing changes - user217683
  • The certificate is not valid, the connection is not installed. - Monk
  • @monk Yes, it is clear that it is not valid. This should be ignored and still get the contents of the page. Google Chrome opens it by 443, after the warning. - user217683
  • Tried to get the details as described on stackoverflow.com/questions/12317771/… ? - Artyom

1 answer 1

To ignore errors, the general practice:

  ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 

Total, the option quite works for me:

  ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; var data = new WebClient().DownloadString("https://www.christopherleeco.com"); 
  • With HttpWebRequest, this option does not work. Is it possible to find out the Status Code of a page through your method? (301 404 403 500 ...) - user217683
  • Found that your example doesn’t work for me, also throws an exception The request was aborted: Could not create SSL/TLS secure channel , I work with VS Express 2013 for Desktop Windows 7 32bit - user217683
  • @ user217683 and what version of dotNet is used? I recommend at least 4.5, on the versions below the behavior may differ. - Monk
  • If I understand you correctly, the project uses .NET Framework 4.5 - user217683