Configure Kestrel for HTTPS using environmnet variables

10/28/2019

I am trying to setup an ASPNET.Core 3.0 web app using Kubernetes but I am unable to get Kestrel work with https.

I found some information searching the web regarding two environment variables I can declare to pass the path and the password for the certificate.

I've made a Kubernetes deployment using those variables like so:

    spec:
      containers:
      - env:
        - name: ASPNETCORE_URLS
          value: http://+:80;https://+:443
        - name: ASPNETCORE_KESTREL_CERTIFICATE_PASSWORD
          value: password
        - name: ASPNETCORE_KESTREL_CERTIFICATE_PATH
          value: /app/tls/certificate.pfx
        volumeMounts:
        - name: storage
          mountPath: "/app/tls"
      volumes:
      - name: storage
        persistentVolumeClaim:
          claimName: tls-storage

I ran the app without https enabled and saw the volume is mounted correctly inside the pod and certificate.pfx is present in /app/tls/.

Anybody know if Kestrel is configured to get the values from those env variables by default or should I also write some code in Program.cs/Startup.cs?

-- Mihaimyh
asp.net-core
kestrel
kubernetes

1 Answer

10/28/2019

I actually just found the correct environment variables:

ASPNETCORE_Kestrel__Certificates__Default__Password

ASPNETCORE_Kestrel__Certificates__Default__Path

-- Mihaimyh
Source: StackOverflow