title: Could not create SSL/TLS secure channel only on Windows Server 2012
body: <p>I have a peculiar problem where a c# app works on all other machines and other client machines I have tested. But does not establish a connection on my clients Windows Server 2012 hosted by his ISP. This app have been working up to about 2 days ago on this machine according to my client and uses .Net4.5.2. I have no idea what changed the last couple of days unfortunately.</p>
  
  <p><strong>What I have tested on this machine:</strong></p>
  
  <ul>
  <li>Using Chrome the url works</li>
  <li>Using Edge the url works</li>
  <li>hitting the URL with curl works</li>
  <li>Using IE11 the url does <strong>not</strong> work</li>
  <li>Using our app does <strong>not</strong> work</li>
  <li>Using a quick test app does <strong>not</strong> work</li>
  </ul>
  
  <p>This is the same no matter what settings I change on the server or in the app.</p>
  
  <p><strong>Error from my app:</strong></p>
  
  <pre><code>AuthResponse is null: False 
  AuthResponse ErrorException: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
     at System.Net.HttpWebRequest.GetRequestStream(TransportContext&amp; context)
     at System.Net.HttpWebRequest.GetRequestStream()
     at RestSharp.Http.WriteRequestBody(HttpWebRequest webRequest)
     at RestSharp.Http.PostPutInternal(String method)
     at RestSharp.Http.AsPost(String httpMethod)
     at RestSharp.RestClient.DoExecuteAsPost(IHttp http, String method)
     at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)
  AuthResponse ErrorMessage: The request was aborted: Could not create SSL/TLS secure channel.
  </code></pre>
  
  <p><strong>Error from IE11:</strong></p>
  
  <pre><code>Turn on TLS 1.0, TLS 1.1, and TLS 1.2 in Advanced settings and try connecting to  again. If this error persists, it is possible that this site uses an unsupported protocol or cipher suite such as RC4 (link for the details), which is not considered secure. Please contact your site administrator.
  </code></pre>
  
  <p><strong>Errors From Event Viewer:</strong></p>
  
  <pre><code>A fatal alert was received from the remote endpoint. The TLS protocol defined fatal alert code is 40.
  A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205.
  A fatal error occurred while creating an SSL client credential. The internal error state is 10013.
  </code></pre>
  
  <p>There are a lot of these errors in event viewer, I just copied three of them in case they are actually relevant.</p>
  
  <p><strong>What I have tried:</strong></p>
  
  <p>I used <a href="https://www.nartac.com/Products/IISCrypto" rel="noreferrer">IISCrypto</a> to change and configure all manner of settings and testing in between. All with the same results. I have modified my app with quite a few changes I have found by searching all with the same results as well. Some of the code changes I made below:</p>
  
  <pre><code>System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
  ServicePointManager.Expect100Continue = true;
  System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =&gt; true;
  </code></pre>
  
  <p>This is not all the changes I tried. I tried all kinds of different variations as well such as only tls1.2. I have used my little test app as well to connect to other https sites like google and my other rest service and no error is reported on this machine.</p>
  
  <p>Our Auth server uses Lets Encrypts certificates and uses OAth and only accepts tls2.1. I have hit another REST Api that we use that also use Lets Encrypt and that is working. I don't know if I need to update the certificate store (if that is possible), or if there is a setting I'm missing. I'm honestly at a loss here.</p>
  
  <p><strong>Test app source if that helps at all:</strong></p>
  
  <pre><code>static async Task test(string url)
  {
      // Call asynchronous network methods in a try/catch block to handle exceptions.
      try
      {
          HttpClient httpClient = new HttpClient();
          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  
          ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =&gt; true;
  
          var result = await httpClient.GetAsync(url);
          MessageBox.Show(result.StatusCode.ToString());
      }
      catch (HttpRequestException e)
      {
          MessageBox.Show(e.ToString());
      }
  }
  </code></pre>