.net 移动的客户端在调用StartAsync()方法时获得“CERTIFICATE_VERIFY_FAILED”的SignalR

disho6za  于 2022-11-26  发布在  .NET
关注(0)|答案(2)|浏览(168)

从我的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

有人能帮我解决这个CERTIFICATE_VERIFY_FAILED吗?
下面是堆栈跟踪:
[错误]无法行程的严重例外状况:System.Net.Http.HttpRequestException:无法建立SSL连接,请参阅内部异常。---〉系统。安全。身份验证。AuthenticationException:验证失败,请查看内部异常。---〉Mono.Btls.MonoBtlsException:SSL错误:1000007d:SSL例程:打开SSL内部:证书验证失败03 - 21 23:59:57.526 E/单通道RT(6307):在/用户/构建器/jenkins/工作空间/归档-mono/2019 - 08/android/发布/外部/boringssl/ssl/握手_客户端。c:1132 03 - 21 23:59:57.526 E/mono-rt(6307):在/用户/构建器/jenkins/工作区/归档-mono/2019 - 08/android/发布/mcs/class/系统/Mono. Btls/MonoBtlsContext. cs:220 03 - 21 23:59:57.526 E/mono-rt(6307)中,处理握手()[0x00042]:在/用户/构建器/jenkins/工作空间/归档-mono/2019 - 08/android/release/mcs/class/系统/Mono. Net.安全性/移动验证流。处理握手(Mono. Net.安全性.异步操作状态状态,系统.布尔重新协商)[0x000da]在/用户/构建器/jenkins/工作空间/归档-mono/2019 - 08/android/release/mcs/class/系统/Mono. Net.安全性/移动验证流。cs:840 03 - 21 23:59:57.526 E/mono-rt(6307):如果您有任何问题,请与我们联系。如果您有任何问题,请与我们联系。在/用户/构建器/jenkins/工作区/归档-mono/2019 - 08/android/发布/mcs/class/系统/Mono. Net.安全/异步协议请求中运行(Mono. Net.安全.异步操作状态)[0x00000]。[0x000fc]在/用户/构建器/jenkins/工作区/归档-mono/2019 - 08/android/发布/mcs/class/系统/Mono. Net.安全性/异步协议请求. cs:223 03 - 21 23:59:57.526 E/mono-rt(6307):- --内部异常堆栈跟踪结束---03 - 21 23:59:57.526 E/mono-rt(6307):[0x0025c]在/用户/构建器/jenkins/工作空间/archive-mono/2019 - 08/android/release/mcs/class/系统/Mono. Net.安全性/移动验证流。cs:406 03 - 21 23:59:57.526 E/mono-rt(6307):在/用户/构建器/jenkins/工作空间/archive-mono/2019 - 08/android/release/外部/corefx/src/系统. Net. Http/源/系统/网络/Http/套接字HttpHandler/连接助手中,创建SSL连接异步核心(系统. IO.流流,系统. Net.安全性. SSL客户端身份验证选项SSL选项,系统.线程,取消令牌取消令牌)[0x0007b]。- --内部异常堆栈跟踪结束---03 - 21 23:59:57.526 E/mono-rt(6307):在/Users/builder/jenkins/workspace/archive-mono/2019 - 08/android/release/external/corefx/src/System. Net. Http/src/System/Net/Http/套接字Http处理程序/连接助手中建立SSL连接异步核心(系统. IO.流数据流,系统. Net.安全性,SSL客户端身份验证选项SSL选项,系统.线程,取消令牌取消令牌)[0x000f6]在/Users/builder/jenkins/workspace/archive-mono/2019 - 08/android/release/external/corefx/src/System. Net. Http/src/系统/Net/Http/套接字Http处理程序/连接助手中。在/用户/构建器/jenkins/工作区/归档-mono/2019 - 08/android/发布/外部/corefx/src/公共/src/核心库/系统/线程/任务/值任务中,获取_结果()[0x0001b]。在/用户/构建器/jenkins/工作区/archive-mono/2019 - 08/android/release/外部/corefx/src/系统. Net. Http/src/系统/网络/Http/套接字HttpHandler/HttpConnectionPool. cs:529中,系统.线程.任务.值任务'1 [TResult]创建任务)[0x000a2]
下面是异常详细信息:

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.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 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.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.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

8ehkhllq

8ehkhllq1#

通过搜索堆栈溢出找出答案,下面是解决方案的链接:
忽略signalR核心客户端的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();
9q78igpj

9q78igpj2#

使用AndroidClientHandler(Android的SSL库)而不是HttpClientHandler

相关问题