TLS 握手问题 - 身份验证失败

问题描述

.Net Core 3.1 将一台服务器与另一台服务器通信时出错,两台服务器弱密码禁用时的密码套装相同。

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.AggregateException: One or more errors occurred. (The SSL connection Could not be established,see inner exception.)
---> System.Net.Http.HttpRequestException: The SSL connection Could not be established,see inner exception.
---> System.Security.Authentication.AuthenticationException: Authentication Failed,see inner exception.
---> System.ComponentModel.Win32Exception (0x80090326): The message received was unexpected or badly formatted.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message,AsyncProtocolRequest asyncRequest,ExceptiondispatchInfo exception)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming,Int32 count,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer,Int32 readBytes,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst,Byte[] buffer,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult,CancellationToken cancellationToken)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(SslClientAuthenticationoptions sslClientAuthenticationoptions,CancellationToken cancellationToken,AsyncCallback asyncCallback,Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__65_0(SslClientAuthenticationoptions arg1,CancellationToken arg2,AsyncCallback callback,Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod,Func`2 endFunction,Action`1 endAction,TArg1 arg1,TArg2 arg2,Object state,TaskCreationoptions creationoptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,Action`1 endMethod,Object state)
at System.Net.Security.SslStream.AuthenticateAsClientAsync(SslClientAuthenticationoptions sslClientAuthenticationoptions,CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream,SslClientAuthenticationoptions sslOptions,CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.ConnectAsync(HttpRequestMessage request,Boolean allowHttp2,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.GethttpconnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.SendWithRetryAsync(HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellation

尝试强行使用 TLS 1.2 进行通信,但没有成功?

示例代码

var MyClient = _httpClientFactory.CreateClient();
                MyClient.BaseAddress = new Uri(DomainURL);
var getTask = MyClient.GetAsync(string.Format(VerifyUser?Guid={0}&PersonID={1},personid));
getTask.Wait();

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)