错误Ocelot网关.Net Core 6,IIS本地中的Puscblish

zpgglvta  于 2022-11-07  发布在  Postman
关注(0)|答案(1)|浏览(169)

我试图在IIS本地发布我的API网关,但是,他们总是显示错误502(坏网关),我找不到问题,请帮助我知道我应该走哪条路。

{
  "Routes": [
    {
      "UpstreamPathTemplate": "/gateway/seguridad/auth",
      "UpstreamHttpMethod": [ "POST" ],
      "DownstreamPathTemplate": "/api/auth",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 7221
        }
      ]
    },
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:8085"
  }
}

我的终结点在POST方法中正常工作,无论是在调试还是在发布中。
我咨询的网址:

https://localhost:8085/gateway/seguridad/auth

尝试运行端点时显示的错误是502(网关错误),在系统事件查看器中,错误如下。

Category: Ocelot.Responder.Middleware.ResponderMiddleware
EventId: 0
SpanId: ce42c03504779a7b
TraceId: c20b3aaf91fe3ccac5d82b8b00b385ae
ParentId: 0000000000000000
RequestId: 40000014-0002-fb00-b63f-84710c7967bb
RequestPath: /gateway/seguridad/auth

requestId: 40000014-0002-fb00-b63f-84710c7967bb, previousRequestId: no previous request id, message: Error Code: ConnectionToDownstreamServiceError Message: Error connecting to downstream service, exception: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
   at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
   at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Ocelot.Requester.HttpClientHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/gateway/seguridad/auth, request method: POST
mpbci0fu

mpbci0fu1#

出现错误:“远程证书无效,因为证书链中存在错误:UntrustedRoot”可能意味着您的计算机不信任您的自签名证书。
在“localhost:7221”上运行的服务是否安装了SSL证书?如果您在浏览器中访问它,您可以确定需要安装哪个证书。
请查看C# Ignore certificate errors?
对于开发时的解决方法,您可以将以下内容添加到程序中:
ServicePointManager.ServerCertificateValidationCallback += sender, cert, chain, sslPolicyErrors) => true;
但是,我不建议在生产系统中这样做。而且,如果你在共享服务器上托管,我会让你的下游服务器在https上

相关问题