Mar*_*lPT 1 authentication exception ssl-certificate signalr xamarin
从我的 Xamarin 客户端调用 SignalR StartAsync 会抛出我:
[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
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个 CERTIFICATE_VERIFY_FAILED 吗?
这是堆栈跟踪:
[错误] 致命未处理异常:System.Net.Http.HttpRequestException:无法建立 SSL 连接,请参阅内部异常。---> System.Security.Authentication.AuthenticationException:身份验证失败,请参阅内部异常。---> Mono.Btls.MonoBtlsException: Ssl 错误:1000007d:SSL 例程:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED 03-21 23:59:57.526 E/mono-rt (6307): 在 /Users/builder/jenkinive mono/2019-08/android/release/external/boringssl/ssl/handshake_client.c:1132 03-21 23:59:57.526 E/mono-rt (6307): 在 Mono.Btls.MonoBtlsContext.ProcessHandshake () [20x000 ] 在 /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):在 Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.
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.ValueTask1[TResult].get_Result() [0x0001b] 在 /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): 在 System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) [0x000a2 ] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:529
这里是异常详细信息:
System.Net.Http.HttpRequestException Message=无法建立 SSL 连接,请参阅内部异常。Source=mscorlib StackTrace:在 System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(System.IO.Stream 流、System.Net.Security.SslClientAuthenticationOptions sslOptions、System.Threading.CancellationToken 取消令牌)[0x000f6] 在 /Users/builder/jenkins/ workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:176 在 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.ValueTask1[TResult].get_Result() [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks /ValueTask.cs:813 在 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.ValueTask1[TResult].get_Result() [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks /ValueTask.cs:813 在 System.Net.Http.HttpConnectionPool.SendWithRetryAsync(System.Net.Http.HttpRequestMessage 请求,System.Boolean doRequestAuth,System.Threading.CancellationToken 取消令牌)[0x0003f] 在 /Users/builder/jenkins/workspace /archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 在 System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage 请求,System.Threading.CancellationToken 取消令牌)[0x00070] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.网。Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 在 Microsoft.AspNetCore.Http.Connections.Client.Internal.AccessTokenHttpMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage 请求,System.Threading.CancellationToken 取消令牌) [0x000ff] 在 <143c191c2fa54eed93ae7f23c7781c1f>:0 在 Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage 请求,System.Threading.CancellationToken 取消令牌)[0x01c21f901c21ac21c21f95c21c21f901ac21f921ac21f921ac21f901c37e90x71c2f901ac1ae925c7f90c1ae95c1f95c7e9000ff] 0 在 System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task<143c191c2fa54eed93ae7f23c7781c1f>:0 中的 [0x000ff] Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage 请求,System.Net.Http.HttpRequestMessage 请求,System.Threading.9CancellationToken 中的 <143c191c2fa54eed93ae7f23c7781c1f>:0) 143c191c2fa54eed93ae7f23c7781c1f>:0 在 System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task<143c191c2fa54eed93ae7f23c7781c1f>:0 中的 [0x000ff] Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage 请求,System.Net.Http.HttpRequestMessage 请求,System.Threading.9CancellationToken 中的 <143c191c2fa54eed93ae7f23c7781c1f>:0) 143c191c2fa54eed93ae7f23c7781c1f>:0 在 System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task任务.任务任务.任务1[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.ValueTask1[TResult].get_Result() [0x0001b] 在 /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.CancellationTokenCancellationToken) [0x000a5] in :0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner (System.Threading.CancellationToken) [0x0019e] in :0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in :0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancelationToken) [0x00091] in :0 在 MobileApp.Services.HubService.SendMessage (MobileApp.Models.Message 消息) [0x00042] 在 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 在 System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0(System.Object 状态)[0x00000] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08 /android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 在 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] :0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.70(intptr,intptr)
谢谢你们
通过搜索堆栈溢出来查找,这是解决方案的链接:
使用 signalR Core Client 忽略 SSL 错误
刚刚向我的 HubConnectionBuilder 添加了选项,它起作用了!!
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();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
763 次 |
| 最近记录: |