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?

5
  • 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. I suggest you watch/read something about SSL to better understanding certificate, see this 6minute video Commented Aug 23, 2021 at 10:41
  • @Max When using Visual Studio for debug purpose, the recommendation is to NOT COPY certificates in containers (learn.microsoft.com/en-us/aspnet/core/security/…). Commented Aug 23, 2021 at 10:59
  • Try some suggestions and methods in this thread:stackoverflow.com/questions/53300480/… Commented Aug 24, 2021 at 2:05
  • @DanielZhang-MSFT Done before writing this post Commented Aug 24, 2021 at 7: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 Commented Aug 25, 2021 at 1:41

1 Answer 1

0

It could be the certificate being used for that specific project has an issue. You can try opening the folder %appdata%\Roaming\ASP.NET\Https and deleting <project name>.pfx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.