title: Unable to create a dev certificate for an ASP.NET Core Web App in a Docker container
body: <p>I'm trying to create a simple ASP.NET-Core 2.1 Web App that runs in Docker and forces HTTPS.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Luckily, there are some good docs that help explain/talk about this:</p>
  
  <ul>
  <li><a href="https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https-development.md" rel="nofollow noreferrer">https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https-development.md</a></li>
  <li><a href="https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https.md" rel="nofollow noreferrer">https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/aspnetcore-docker-https.md</a></li>
  <li><a href="https://github.com/aspnet/Docs/issues/3310" rel="nofollow noreferrer">https://github.com/aspnet/Docs/issues/3310</a></li>
  <li><a href="https://github.com/aspnet/Docs/issues/6199" rel="nofollow noreferrer">https://github.com/aspnet/Docs/issues/6199</a></li>
  </ul>
  
  <p>But everytime I try and start the first main step -> creating a cert, I get the following errors:</p>
  
  <pre><code>C:\Users\justi&gt;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&gt;dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\hornet.apigateway.website.public.pfx -p secretpassword
  A valid HTTPS certificate is already present.
  </code></pre>
  
  <p>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.</p>
  
  <p>The above command was based on the examples in the links, above.</p>
  
  <p>I feel like the error message is incorrect and the <em>real</em> error message isn't being displayed?</p>
  
  <hr>
  
  <h3>Update</h3>
  
  <p>Just in case I've messed up my Docker file stuff, here's my 2x docker-compose files:</p>
  
  <pre><code>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/
  </code></pre>