Step by step: Expose ASP.NET Core over HTTPS with Docker

This week I decided to modify the sample of my previous post: Step by step: Scale ASP.NET Core with Docker Swarm so you can add TLS to your ASP.NET Core applications and Dockerize it.

Let’s see how I changed the application in order to make it work:

1. Add HTTPS support for Kestrel
2. Configure Kestrel to use HTTPS

Now It’s time to show you how to Dockerize the application:

1. Create a dockerfile
2. Create a Docker image
3. Test the Docker image
4. Run the Docker image as a daemon process

You can get a copy of the docker file here:

Hope it helps!

6 thoughts on “Step by step: Expose ASP.NET Core over HTTPS with Docker

  1. Please, could you provide example with “Mutual Certificate Authentication”
    with core and docker, I’am try to use HttpsConnectionFilterOptions.ClientCertificateValidation
    but it doesn’t work with .NET 4.6 client (and works only with .net core client)

  2. I tried your scripts to generate self-signed certificate. Everything worked fine, Kestrel started with this certificate, but failed on any request attempt with Win32Exception: “The credentials supplied to the package were not recognized”.

    It tuned out that the issue was with the certificate itself. I was able to overcome problems with certificate from the example here:

    1. Hi glad you fixed. Just in case you wanna try creating the self signed certicate with powershell use the following lines:

      # Create the cert
      $cert = New-SelfSignedCertificate `
      -CertStoreLocation "cert:\CurrentUser\My" `
      -Subject "CN=[NAME OF YOUR CN HERE]" `
      -KeySpec KeyExchange

      # Password for the cert
      $secpasswd = ConvertTo-SecureString [YOUR PASSWORD HERE] -AsPlainText -Force

      # Export the cert
      Export-PfxCertificate `
      -cert "cert:\CurrentUser\my\$($cert.Thumbprint)" `
      -FilePath [THE FILE NAME TO STORE THE PFX].pfx `
      -Password $secpasswd `
      -ErrorAction SilentlyContinue

      I used the resulting certificate with the specified password to run the app on windows without any problem.

      Hope it helps!

Leave a Reply