I'm trying to create a simple ASP.NET-Core 2.1 Web App that runs in Docker and forces HTTPS.
If I don't force HTTPS, the web app runs fine in the Docker instance. If I force HTTPS, or manually try to hit the HTTPS port, I get an "unable to connect" error or something nasty, like it.
So from my understanding, I need to somehow copy the trusted self-signed dev certification from my localhost development machine over to the Docker instance.
Luckily, there are some good docs that help explain/talk about this:
- https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https-development.md
- https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https.md
- https://github.com/aspnet/Docs/issues/3310
- https://github.com/aspnet/Docs/issues/6199
But everytime I try and start the first main step -> creating a cert, I get the following errors:
C:\Users\justi>dotnet dev-certs https --clean Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates. C:\Users\justi>dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\hornet.apigateway.website.public.pfx -p secretpassword A valid HTTPS certificate is already present. But as you can see, I just tried to clean my cert store (which I did get asked to confirm the deleting of the cert) and then try to create a new one.
The above command was based on the examples in the links, above.
I feel like the error message is incorrect and the real error message isn't being displayed?
Update
Just in case I've messed up my Docker file stuff, here's my 2x docker-compose files:
docker-compose.yml apigateway.website.public: image: hornet/apigateway.website.public build: context: . dockerfile: src/Api Gateways/ApiGateway.Website.Public/Dockerfile #ports: # - "5000:443" depends_on: - microservice1.api - microservice2.api docker-compose.override.yml apigateway.website.public: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=https://localhost;http://localhost - ASPNETCORE_HTTPS_PORT=5001 ports: # NOTE: need to copy the dev cert over to the container # REF: o) https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https-development.md # o) https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https.md # o) https://github.com/aspnet/Docs/issues/3310 # o) https://github.com/aspnet/Docs/issues/6199 - "5000:80" - "5001:443" volumes: - ${APPDATA}/Microsoft/UserSecrets/:/root/.microsoft/usersecrets - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https/