问题描述
我已将解决方案从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 (将#修改为@)