I integrate 3rd party API in my API. That time got error. Maybe this is SSL connection issue.

"data": { "message": "The SSL connection could not be established, see inner exception.", "data": {}, "innerException": { "ClassName": "System.Security.Authentication.AuthenticationException", "Message": "Authentication failed, see inner exception.", "Data": null, "InnerException": { "ClassName": "System.ComponentModel.Win32Exception", "Message": "The message received was unexpected or badly formatted", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": null, "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2147467259, "Source": null, "WatsonBuckets": null, "NativeErrorCode": -2146893018 }, "HelpURL": null, "StackTraceString": " at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)\r

at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r

at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)\r

at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)\r

at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)\r

at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)\r

--- End of stack trace from previous location where exception was thrown ---\r

at System.Net.Security.SslState.ThrowIfExceptional()\r

at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)\r

at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)\r

at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)\r

at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_1(IAsyncResult iar)\r

at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)\r

--- End of stack trace from previous location where exception was thrown ---\r

at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2146233087, "Source": "System.Private.CoreLib", "WatsonBuckets": null }, "stackTrace": " at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r

at System.Threading.Tasks.ValueTask`1.get_Result()\r

at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r

at System.Threading.Tasks.ValueTask`1.get_Result()\r

at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)\r

at System.Threading.Tasks.ValueTask`1.get_Result()\r

at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)\r

at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r

at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r

at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)\r

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", "helpLink": null, "source": "System.Net.Http", "hResult": -2146233087}

and API code is

using (var SB_helper = new SBHelpers(Connection)) { using (var httpClientHandler = new HttpClientHandler()) { httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }; ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072; //send request using (var httpClient = new HttpClient(httpClientHandler)) { string bodyParameter = $"cert={SBConst.Cert}&agentId={SBConst.AgentId}&userId={SBConst.UserNamePrefix + request.UserId}¤cy={request.Currency}&betLimit={request.BetLimit}&language={request.Language}"; var content = new StringContent(bodyParameter, Encoding.UTF8, "application/x-www-form-urlencoded"); HttpResponseMessage response = await client.PostAsync($"{SBConst.APIURL}{SBConst.Method.CreateMember}", content); var responseString = await response.Content.ReadAsStringAsync(); dynamic responseOk = JsonConvert.DeserializeObject(responseString); return response; } } }

This error got on live server. But on localhost and windows 10 that is working fine.

Anyone have idea related to this ?

Thank you in Advance :)