title: Ocelot certificate problem. The SSL connection could not be established, see inner exception
body: <p>I am running in Local using Docker an Ocelot API gateway (https://localhost:5010) service that calls a Dot net core API (https://localhost:5003).</p>
  <p>I used self signed certificates and both services are secure:</p>
  <p><a href="https://i.stack.imgur.com/0FydE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0FydE.png" alt="API certificate" /></a></p>
  <p><a href="https://i.stack.imgur.com/8rQBY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8rQBY.png" alt="Ocelot certificate" /></a></p>
  <p>To make it work locally I add in Ocelot.Development.json:</p>
  <pre><code>      &quot;DownstreamPathTemplate&quot;: &quot;/ActivityTypes&quot;,
        &quot;DownstreamScheme&quot;: &quot;https&quot;,
        &quot;DownstreamHostAndPorts&quot;: [
          {
            &quot;Host&quot;: &quot;xplora.api&quot;,
            &quot;Port&quot;: &quot;443&quot;
          }
        ],
        &quot;UpstreamPathTemplate&quot;: &quot;/ActivityTypes&quot;,
        &quot;UpstreamHttpMethod&quot;: [ &quot;GET&quot; ],
        &quot;RateLimitOptions&quot;: {
          &quot;ClientWhitelist&quot;: [],
          &quot;EnableRateLimiting&quot;: true,
          &quot;Period&quot;: &quot;3s&quot;,
          &quot;PeriodTimespan&quot;: 1,
          &quot;Limit&quot;: 1
        },
        &quot;FileCacheOptions&quot;: { &quot;TtlSeconds&quot;: 30 }
      }
  </code></pre>
  <p>Where xplora.api is the name of the container defined in docker-compose.</p>
  <pre><code>    container_name: xplora.api
      environment:
  </code></pre>
  <p>When I access the Ocelot api gateway I get this error:</p>
  <pre><code>xploraproject-xploraapigateway-1  |       requestId: 0HMDG3PCRH54C:00000001, 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.
  xploraproject-xploraapigateway-1  |        ---&gt; System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
  xploraproject-xploraapigateway-1  |          at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
  xploraproject-xploraapigateway-1  |          at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
  xploraproject-xploraapigateway-1  |          at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
  xploraproject-xploraapigateway-1  |          --- End of inner exception stack trace ---
  xploraproject-xploraapigateway-1  |          at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
  </code></pre>
  <p>I suspect the problem is that when I try to access this services using localhost it works fine because the certificate is assigned to localhost domain but when Ocelot tries to use <a href="https://xplora.api:5003" rel="nofollow noreferrer">https://xplora.api:5003</a> this certificate is not working. Am I right? If so.. how can I make it work? I used  &quot;DangerousAcceptAnyServerCertificateValidator&quot;: true in Ocelot.Development.json and it works but I want a real solution, without using DangerousAcceptAnyServerCertificateValidator.</p>
  <p>Thanks</p>