Unable to configure ASP.NET HTTPS endpoint in Windows docker container Unable to configure ASP.NET HTTPS endpoint in Windows docker container powershell powershell

Unable to configure ASP.NET HTTPS endpoint in Windows docker container


If you want to run in Development using a self-signed certificate, you might follow here article. For Production scenarios instead here.

In a nutshell, the suggested approach differs from the one you are using as two volumes could be mounted referencing the folders containing your certificate and your dotnet secrets.

You would map your host "%USER%\.aspnet\https" folder to your guest "/root/.aspnet/https/" and your host "%APPDATA%\microsoft\UserSecrets\" folder to your guest "/root/.microsoft/usersecrets".

The main difference between Production and Development is that in Production you would not use secrets and you will need to pass the folder containing your certificate and the password to access it using the environment variables:

  • ASPNETCORE_Kestrel__Certificates__Default__Path
  • ASPNETCORE_Kestrel__Certificates__Default__Password

Kestrel will go looking on your Linux guest in the "/root/.aspnet/https/" folder for a certificate that has the same name as your project.

If I enable tracing using your appsettings.Development.json:

      "Logging": {        "LogLevel": {          "Default": "Trace ",          "System": "Trace ",          "Microsoft": "Trace"        }      }

I see the error below shown if I start running my sample app without a certificate mounted in the guest container:

    root@7afc71f877ce:/app# dotnet helloworld.dll    dbug: Microsoft.Extensions.Hosting.Internal.Host[1]          Hosting starting    dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[2]          Failed to locate the development https certificate at '/root/.aspnet/https/helloworld.pfx'.    dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[1]          Unable to locate an appropriate development https certificate.    crit: Microsoft.AspNetCore.Server.Kestrel[0]          Unable to start Kestrel.    System.InvalidOperationException: 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'.

Hope it helps.