1

I have an existing ASP.NET 5 application. I can start it normally in Visual Studio 2019 with F5. The app has https enabled. I add docker support to the app, using the Visual Studio tooling "Add Docker Support". The docker file is created normally, the image is built and the container successfully started by Visual Studio. However, then I hit F5 (with the Docker profile), I get the following exception:

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.

The app continues to work normally if started with IIS Express or Kestrel. Using the suggested dotnet dev-certs commands doesn't solve.

Moreover:

  1. If I disable https in launchSettings.json
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
      "publishAllPorts": true,
      "useSSL": false <-
    }

then no problems (http obviously)

  1. If I create a brand new ASP.NET 5 Web App with HTTPS and Docker support in the same machine, F5 with Docker runs fine straight away (with https).

Can anyone suggest what the problem could be or how to troubleshoot it?

Franco Tiveron
  • 2,364
  • 18
  • 34
  • The error says: "Hey I don't have a default certificate with encrypting the connection and/or you don't specify it". You must copy and configure the certificate to the docker image see [this](https://learn.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide). I suggest you watch/read something about SSL to better understanding certificate, see this [6minute video](https://www.youtube.com/watch?v=33VYnE7Bzpk) – Max Aug 23 '21 at 10:41
  • @Max When using Visual Studio for debug purpose, the recommendation is to NOT COPY certificates in containers (https://learn.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-5.0#certificates). – Franco Tiveron Aug 23 '21 at 10:59
  • Try some suggestions and methods in this thread:https://stackoverflow.com/questions/53300480/unable-to-configure-https-endpoint-no-server-certificate-was-specified-and-the – DanielZhang-MSFT Aug 24 '21 at 02:05
  • @DanielZhang-MSFT Done before writing this post – Franco Tiveron Aug 24 '21 at 07:55
  • When you try the following steps, what specific error message appears? 1.used certmgr to remove all localhost certs:Open certmgr.msc (Current User) Delete all localhost certs at: - Certificates-Current User /Personal/Certificates 2.dotnet dev-certs https --clean 3.dotnet dev-certs https --trust 4.dotnet dev-certs https --check – DanielZhang-MSFT Aug 25 '21 at 01:41

0 Answers0