title: Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback
body: <p>I'm trying to establish SSL/TLS connection to <strong>test server with self-signed certificate</strong>. Communication through unsecure channel worked without issues.</p>
  
  <p>Here is my sample code, which I've written based on this solutions:
  <a href="https://stackoverflow.com/questions/12553277/allowing-untrusted-ssl-certificates-with-httpclient">Allowing Untrusted SSL Certificates with HttpClient</a>
  <a href="https://stackoverflow.com/questions/2675133/c-sharp-ignore-certificate-errors">C# Ignore certificate errors?</a>
  <a href="https://stackoverflow.com/questions/15205814/net-client-connecting-to-ssl-web-api">.NET client connecting to ssl Web API</a></p>
  
  <pre><code>ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =&gt; true;
  
  var c = new HttpClient();
  var r = c.GetAsync("https://10.3.0.1:8443/rest/v1").Result;
  if (r.IsSuccessStatusCode)
  {
      Log.AddMessage(r.Content.Get&lt;string&gt;());
  }
  else
  {
      Log.AddMessage(string.Format("{0} ({1})", (int)r.StatusCode, r.ReasonPhrase));
  }
  </code></pre>
  
  <p>also tried this:</p>
  
  <pre><code>var handler = new WebRequestHandler();
  handler.ServerCertificateValidationCallback = delegate { return true; };
  var c = new HttpClient(handler);
  ...
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  </code></pre>
  
  <p>but each time I've got an exception:</p>
  
  <pre><code>InnerException: System.Net.Http.HttpRequestException
     _HResult=-2146233088
     _message=An error occurred while sending the request.
     HResult=-2146233088
     IsTransient=false
     Message=An error occurred while sending the request.
     InnerException: System.Net.WebException
          _HResult=-2146233079
          _message=The request was aborted: Could not create SSL/TLS secure channel.
          HResult=-2146233079
          IsTransient=false
          Message=The request was aborted: Could not create SSL/TLS secure channel.
          Source=System
          StackTrace:
               at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
               at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
          InnerException: 
  </code></pre>
  
  <p>What do I do wrong? Why I can't connect to this server (which has invalid-self-signed certificate)</p>