I have .net core 7 solution which is dockerized in a compose file like below:
version: '3.4'
services:
sqldb:
image: mcr.microsoft.com/azure-sql-edge
ports:
- "1433:1433"
environment:
- SA_PASSWORD=PASSWORD
- ACCEPT_EULA=Y
product-api:
image: ${DOCKER_REGISTRY-}productapi
build:
context: .
dockerfile: src/productapi/WebApi/Dockerfile
depends_on:
- "sqldb"
live-api:
image: ${DOCKER_REGISTRY-}live
build:
context: .
dockerfile: src/LiveAPI/Web/Dockerfile
depends_on:
- "sqldb"
- "product-api"
and a compose override like below:
version: '3.4'
services:
product-api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "5200:443"
- "5201:80"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
live-api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "5300:443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
So, when I try to call rest api in "product-api" from "live-api" service, I get the following exception:
The SSL connection could not be established, see inner exception. -> The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
I tried many solutions, but none of them has been worked for me!
What I tried:
Disable SSL validation in "live-api" service.
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
{
// local dev, just approve all certs
if (development) return true;
return errors == SslPolicyErrors.None;
};
How I tried to call the API:
- https://product-api:443
- https://product-api
- https://host.docker.internal:5200