title: "message": "The SSL connection could not be established, see inner exception." in Windows Server 2012 R2
body: <p>I integrate 3rd party API in my API. That time got error. Maybe this is SSL connection issue.</p>
  <pre><code>&quot;data&quot;: {
  &quot;message&quot;: &quot;The SSL connection could not be established, see inner exception.&quot;,
  &quot;data&quot;: {},
  &quot;innerException&quot;: {
    &quot;ClassName&quot;: &quot;System.Security.Authentication.AuthenticationException&quot;,
    &quot;Message&quot;: &quot;Authentication failed, see inner exception.&quot;,
    &quot;Data&quot;: null,
    &quot;InnerException&quot;: {
      &quot;ClassName&quot;: &quot;System.ComponentModel.Win32Exception&quot;,
      &quot;Message&quot;: &quot;The message received was unexpected or badly formatted&quot;,
      &quot;Data&quot;: null,
      &quot;InnerException&quot;: null,
      &quot;HelpURL&quot;: null,
      &quot;StackTraceString&quot;: null,
      &quot;RemoteStackTraceString&quot;: null,
      &quot;RemoteStackIndex&quot;: 0,
      &quot;ExceptionMethod&quot;: null,
      &quot;HResult&quot;: -2147467259,
      &quot;Source&quot;: null,
      &quot;WatsonBuckets&quot;: null,
      &quot;NativeErrorCode&quot;: -2146893018
    },
    &quot;HelpURL&quot;: null,
    &quot;StackTraceString&quot;: &quot;   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)\r\n   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Net.Security.SslState.ThrowIfExceptional()\r\n   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)\r\n   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)\r\n   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)\r\n   at System.Net.Security.SslStream.&lt;&gt;c.&lt;AuthenticateAsClientAsync&gt;b__47_1(IAsyncResult iar)\r\n   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)&quot;,
    &quot;RemoteStackTraceString&quot;: null,
    &quot;RemoteStackIndex&quot;: 0,
    &quot;ExceptionMethod&quot;: null,
    &quot;HResult&quot;: -2146233087,
    &quot;Source&quot;: &quot;System.Private.CoreLib&quot;,
    &quot;WatsonBuckets&quot;: null
  },
  &quot;stackTrace&quot;: &quot;   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r\n   at System.Threading.Tasks.ValueTask`1.get_Result()\r\n   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n   at System.Threading.Tasks.ValueTask`1.get_Result()\r\n   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)\r\n   at System.Threading.Tasks.ValueTask`1.get_Result()\r\n   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)\r\n   at weplay.api.Helpers.SexyBaccarat_Game.SexyBaccarat.SexyBaccaratHelpers.SexyBaccarateRegisterAsync(ProfileRequest request) in E:\\Yudiz\\Projects\\W\\WeplayDevOps\\weplay.api\\Helpers\\SexyBaccarat_Game\\SexyBaccarat\\SexyBaccaratHelpers.cs:line 125&quot;,
  &quot;helpLink&quot;: null,
  &quot;source&quot;: &quot;System.Net.Http&quot;,
  &quot;hResult&quot;: -2146233087}
  </code></pre>
  <p>and API code is</p>
  <pre><code>using (var SB_helper = new SBHelpers(Connection))
              {
                  using (var httpClientHandler = new HttpClientHandler())
                  {
                      httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
                      httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =&gt; { return true; };
                      ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072;
                      //send request
                      using (var httpClient = new HttpClient(httpClientHandler))
                      {
                          string bodyParameter = $&quot;cert={SBConst.Cert}&amp;agentId={SBConst.AgentId}&amp;userId={SBConst.UserNamePrefix + request.UserId}&amp;currency={request.Currency}&amp;betLimit={request.BetLimit}&amp;language={request.Language}&quot;;
                          var content = new StringContent(bodyParameter, Encoding.UTF8, &quot;application/x-www-form-urlencoded&quot;);
                          HttpResponseMessage response = await client.PostAsync($&quot;{SBConst.APIURL}{SBConst.Method.CreateMember}&quot;, content);
                          var responseString = await response.Content.ReadAsStringAsync();
                          dynamic responseOk = JsonConvert.DeserializeObject(responseString);
                          return response;
                      }
                  }
              }
  </code></pre>
  <p>This error got on live server. But on <strong>localhost</strong> and <strong>windows 10</strong> that is working fine.</p>
  <p>Anyone have an idea on how to solve this?</p>