C#C
C#3y ago
Denis

✅ DEV Certificate invalid password for ASP.NET in docker

I'm using docker compose orchestration for my solution containing ASP.NET projects.

I've created a DEV certificate using dotnet dev-certs https -t -p changeit
The password for the certificate is supposed to be changeit

In the docker-compose-override.yml I've configured the path to the certificate and the password.
version: '3.4'

services:
  grpcserver:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/GrpcServer.pfx
      - ASPNETCORE_Kestrel__Certificates__Default__Password="changeit"
    ports:
      - "16080:80"
      - "16443:443"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro


The path should be correct; however, the password is not working - I get an exception:

System.Security.Cryptography.CryptographicException: 'The certificate data cannot be read with the provided password, the password may be incorrect.'

When trying to check the certificates password using openssl, I also get an invalid password error.
Input: openssl pkcs12 -in GrpcServer.pfx -noout
Output: Mac verify error: invalid password?

Might be because I'm using the command incorrectly, but still... in both cases it is incorrect.

What am I doing wrong?
Was this page helpful?