I have 2 .NET core projects that work perfectly with each other when I run the normal, I have an API and an MVC UI. When I run them in docker containers, I go on my API with swagger, I figured out how to connect my PostgreSQL and insert data successfully. When I go on my UI and I call the API I get this error: An unhandled exception occurred while processing the request AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors. I created a certificate and have it in my .NET project. I am guessing I have to do something different to make this work with a container. (If this is what is wrong, I’m not sure yet.) To put it in my normal project I did this.
.UseKestrel(serverOptions =>
{
serverOptions.Listen(IPAddress.Loopback, 5010);
serverOptions.Listen(IPAddress.Loopback, 5011, listenOptions =>
{
listenOptions.UseHttps("localpfx.pfx", "password");
});
});
I have a Dockerfile in my .NET core project. I am not using docker-compose. Any ideas on how to get my UI to call my API both running in separate containers? This is the last part of my project. Thank you.
P.S.
MVC UI project = "httpPort": 5010, "sslPort": 5011
API project = "httpPort": 5000, "sslPort": 5001
Edit: Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
#USER ContainerAdministrator
#RUN net localgroup administrators /add "User Manager\ContainerUser"
#USER ContainerUser
WORKDIR /app
EXPOSE 5011
#EXPOSE 5010
EXPOSE 80
ENV ASPNETCORE_ENVIRONMENT=Development
#ENV ASPNETCORE_URLS=https://*:5011
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["UserUISolution.csproj", ""]
RUN dotnet restore "./UserUISolution.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "UserUISolution.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "UserUISolution.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "UserUISolution.dll"]