解密操作失败,查看内部异常

2024-04-04

我正在使用 Visual Studio 2017 和 .NET Core 2.x。我已经建立了两个项目。第一个是后端 API(https://本地主机:51637 https://localhost:51637)。第二个是前端网站(https://本地主机:54146 https://localhost:54146)。前端网站调用后端API。它们都在我的机器上本地运行。

问题是,当前端尝试向 API 发送请求时,我收到此异常

info: Microsoft.AspNetCore.Server.Kestrel[20]
    Connection id "0HLKNTHFLCEA9" request processing ended abnormally.
System.IO.IOException: The decryption operation failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate
    --- End of inner exception stack trace ---
    at System.Net.Security.SslStreamInternal.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.AdaptedPipeline.ReadInputAsync(Stream stream)
    at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
    at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
    at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
    at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.BeginRead(ValueTask`1& awaitable)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication`1 application)

这个神秘的错误也可能发生在两个正在开发的 .NET Core 应用程序之间,其中 .NET 应用程序是您的自托管网站或 API,另一个是 .NET 客户端控制台应用程序或其他应用程序。

服务器端错误按照上面的OP转储,客户端错误是:

System.Net.Http.HttpRequestException:无法建立 SSL 连接,请参阅内部异常。 ---> System.Security.Authentication.AuthenticationException:根据验证过程,远程证书无效。

运行此命令以信任开发证书并解决问题。

dotnet dev-certs https -t -v

更多信息请点击这里。

https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解密操作失败,查看内部异常 的相关文章

随机推荐