Home > front end >  Debug dockercompose Visual Studio ASP.NET Core 2.2 over HTTPS getting error
Debug dockercompose Visual Studio ASP.NET Core 2.2 over HTTPS getting error

Time:03-23

I'm struggling with running Docker compose ASP.NET Core 2.2. I'm setting the following:

DockerFile

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
RUN apt update && apt upgrade -y
WORKDIR /app
EXPOSE 80
EXPOSE 443
...

docker-compose-override.yml

  identity-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - Logging__LogLevel__Default=Warning
      - ASPNETCORE_URLS=https:// :443;http:// :80
      - ASPNETCORE_Kestrel__Certificates__Default__Password=123
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    ports:
      - "5015:80"
      - "6015:443"
    networks:
      - default
    volumes:
      - ~/.aspnet/https:/https:ro

I've already generated a certificate and configured the local machine from enter image description here

Output certificate like below:

enter image description here

But when I press F5 to debug docker-compose, I get the following error

Interop.Crypto.OpenSslCryptographicException: 'error:2006D080:BIO routines:BIO_new_file:no such file'

enter image description here

Note: I'm running Windows desktop using the WSL 2 based engine

CodePudding user response:

Oops, the problem is caused by docker-compose-override.yml

volumes:
  - ~/.aspnet/https:/https:ro

You should point out exactly the host path, or do something with 2 steps like this:

  • Step 1. Copy the aspnetapp.pfx into your root project (The same level with dockercompose.override.yml) files.
https/aspnetapp.pfx
  • Step 2. Change the host path in docker-compose-override.yml to
volumes:
  - ./https/aspnetapp.pfx:/https/aspnetapp.pfx:ro
  • Related