title: Restsharp :The SSL connection could not be established
body: <p>An app is run on netcore2.1.5,win7.</p>
  
  <ol>
  <li>I use restsharp to request the API and need to take client certificates, always return the error:</li>
  </ol>
  
  <blockquote>
    <p>The SSL connection could not be established, see inner exception.
    Authentication failed, see inner exception</p>
  </blockquote>
  
  <p>The inner exception content:</p>
  
  <blockquote>
    <p>System.ComponentModel.Win32Exception (0x80090326): 接收到的消息异常，或格式不正确。</p>
  </blockquote>
  
  <p>English version: </p>
  
  <blockquote>
    <p>"The message received is abnormal or not formatted correctly"</p>
  </blockquote>
  
  <ol start="2">
  <li>I user postman to request the API and take the same crt file and response the 
  result result.</li>
  </ol>
  
  <p>My code on below:</p>
  
  <pre class="lang-c# prettyprint-override"><code>string clientCertfile = @"E:\https\client.crt";
  var client = new RestClient("https://apiserver/iocm/app/sec/v1.1.0/login");
  X509Certificate2 certificates = new X509Certificate2(clientCertfile);
  //X509Certificate2 certificates = GetMyX509Certificate(clientCertfile);
  client.ClientCertificates = new X509Certificate2Collection(){ certificates };
  client.RemoteCertificateValidationCallback = 
      new RemoteCertificateValidationCallback(OnRemoteCertificateValidationCallback);
  
  var request = new RestRequest(Method.POST);
  request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
  request.AddParameter("appId", "rIsyJsnMtOrKfpSO90");
  request.AddParameter("secret", "8v0fH0ztunjP1oXT");
  IRestResponse response = client.Execute(request);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AZnFE.jpg" rel="nofollow noreferrer">postman test image</a></p>