微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将Asp.Net Core 2.2升级到3.1无法验证HTTPS连接

如何解决将Asp.Net Core 2.2升级到3.1无法验证HTTPS连接

我已将解决方案从2.2升级到3.1。它由几个项目(API)组成。他们都使用Kestrel和HTTPS。 升级后,当我在localhost上本地运行某些服务时,无法从另一个服务(通过使用HttpClient)调用一个服务,也无法使用Ocelot重新路由它们。在这两种情况下,我都会遇到相同的错误

Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication Failed because the remote party has closed the transport stream.
   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.ForceAuthentication(Boolean receiveFirst,Byte[] buffer,AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult,CancellationToken cancellationToken)
   at System.Net.Security.SslStream.BeginAuthenticateAsServer(SslServerAuthenticationoptions sslServerAuthenticationoptions,CancellationToken cancellationToken,AsyncCallback asyncCallback,Object asyncState)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__69_0(SslServerAuthenticationoptions 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.AuthenticateAsServerAsync(SslServerAuthenticationoptions sslServerAuthenticationoptions,CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.InnerOnConnectionAsync(ConnectionContext context)

当我从邮递员调用每个API时,它正在工作。 此外,当我将所有内容设置为HTTP时,我也会遇到相同的错误

示例代码禁止返回403):

HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://localhost:5004/version");
if (response.IsSuccessstatusCode)
{
      serviceVersion = await response.Content.ReadAsstringAsync();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。