Issue
Calling SignalR StartAsync from my Xamarin client is throwing me:
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
Can anyone help me with this CERTIFICATE_VERIFY_FAILED??
Here is the stack trace:
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED 03-21 23:59:57.526 E/mono-rt ( 6307): at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/boringssl/ssl/handshake_client.c:1132 03-21 23:59:57.526 E/mono-rt ( 6307): at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 03-21 23:59:57.526 E/mono-rt ( 6307): at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:840 03-21 23:59:57.526 E/mono-rt ( 6307): at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) 03-21 23:59:57.526 E/mono-rt ( 6307): at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 03-21 23:59:57.526 E/mono-rt ( 6307): at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223 03-21 23:59:57.526 E/mono-rt ( 6307): --- End of inner exception stack trace --- 03-21 23:59:57.526 E/mono-rt ( 6307): at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:406 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:165 03-21 23:59:57.526 E/mono-rt ( 6307): --- End of inner exception stack trace --- 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x000f6] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:176 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002d8] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:394 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 03-21 23:59:57.526 E/mono-rt ( 6307): at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:529
And here the exception details:
System.Net.Http.HttpRequestException Message=The SSL connection could not be established, see inner exception. Source=mscorlib StackTrace: at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x000f6] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:176 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002d8] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:394 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:529 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 at Microsoft.AspNetCore.Http.Connections.Client.Internal.AccessTokenHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ff] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00095] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x000b3] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:531 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync (System.Uri url, System.Net.Http.HttpClient httpClient, Microsoft.Extensions.Logging.ILogger logger, System.Threading.CancellationToken cancellationToken) [0x00257] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync (System.Uri uri, System.Threading.CancellationToken cancellationToken) [0x00080] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00180] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x0011e] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00091] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) [0x00114] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) [0x001bf] in <143c191c2fa54eed93ae7f23c7781c1f>:0 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x000a5] in :0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner (System.Threading.CancellationToken cancellationToken) [0x0019e] in :0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in :0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) [0x00091] in :0 at MobileApp.Services.HubService.SendMessage (MobileApp.Models.Message message) [0x00042] in C:\Users\sipfe\source\repos\HostelProj v2 - RealTime\MobileApp\MobileApp\Services\HubService.cs:38 at MobileApp.ViewModels.ConversationDetailViewModel.ExecuteSendCommand () [0x00155] in C:\Users\sipfe\source\repos\HostelProj v2 - RealTime\MobileApp\MobileApp\ViewModels\ConversationDetailViewModel.cs:83 at MobileApp.ViewModels.ConversationDetailViewModel.<.ctor>b__34_0 () [0x00028] in C:\Users\sipfe\source\repos\HostelProj v2 - RealTime\MobileApp\MobileApp\ViewModels\ConversationDetailViewModel.cs:55 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in :0 at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in :0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in :0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.70(intptr,intptr)
Thank you guys
Solution
Find out by searching on stack overflow, here is the link for the solution:
Ignore SSL errors with signalR Core Client
just added options to my HubConnectionBuilder and it worked!!
HubConnection = new HubConnectionBuilder()
.WithUrl($"https://10.0.2.2:5001/chatHub", (opts) =>
{
opts.HttpMessageHandlerFactory = (message) =>
{
if (message is HttpClientHandler clientHandler)
// bypass SSL certificate
clientHandler.ServerCertificateCustomValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => { return true; };
return message;
};
})
.Build();
Answered By - MarchalPT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.