title: SSL connection could not be established
body: <p>I've got an issue with sending HTTP requests to as part of automation testing, I want to check URL's status code. When I send the request I have an Exception:</p>
  <blockquote>
  <p>System.AggregateException: 'One or more errors occurred. (The SSL connection could not be established, see inner exception.)'</p>
  </blockquote>
  <p>The inner exceptions are:</p>
  <blockquote>
  <p>HttpRequestException: The SSL connection could not be established, see inner exception.</p>
  </blockquote>
  <blockquote>
  <p>IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.</p>
  </blockquote>
  <blockquote>
  <p>SocketException: An existing connection was forcibly closed by the remote host.</p>
  </blockquote>
  <p>My code:</p>
  <pre><code>    public HttpStatusCode SendRequest(string _url)
      {
          SetUrl(_url);
  
          HttpClientHandler clientHandler = new HttpClientHandler();
          clientHandler.ServerCertificateCustomValidationCallback += (sender, cert, chain, sslPolicyErrors) =&gt; { return true; };
          clientHandler.SslProtocols = SslProtocols.Tls;
  
          HttpClient client = new HttpClient(clientHandler);
  
          var response = client.GetAsync(Url).Result;
  
          StatusCode = response.StatusCode;
  
          return StatusCode;
      }
  </code></pre>
  <p>Thank you in advance !</p>