Sample Header Ad - 728x90

Running Postgresql container using sslmode=verify-full and accessing from WSL, but getting "could not load private key" error

2 votes
0 answers
32 views
i setup my postgresql in container, with hostssl and clientcert=verify-full as an option. I already generate root CA, then sign both server-key.pem and server.pem. then I sign client-key.pem and client.pem using the root CA. Now I try to connect using psql:
$ psql "host=0.0.0.0 port=5433 dbname=mydb user=mydb password=mpdb sslmode=verify-full sslcert=./docker/volumes/db/certs/server.pem sslkey=./docker/volumes/db/certs/server-key.pem sslrootcert=./docker/volumes/db/certs/ca.pem"
I'm in WSL btw. I tried with command terminal in windows too, but both is not working until now. Here's what I've done: - changing the ownership to postgres:postgres on both my container and local file - changing from server-key.pem to client-key.pem - change the file mod to both 600 to key, and 400 and also 600 to cert. Including the root CA. I'm getting this error up until now: > psql: error: connection to server at "0.0.0.0", port 5433 failed: could not load private key file "./docker/volumes/db/certs/server-key.pem": Bx�PV my hba:
hostssl    all             mydb    0.0.0.0/0            cert  clientcert=verify-full
hostnossl  all             mydb    0.0.0.0/0            reject
my conf:
listen_addresses = '*'
port = 5432
the port is map from 5433 -> 5432 on my docker compose file. I've no idea what I'm missing right now and why I have this Bx�PV in my psql error output. Any suggestion?
Asked by Rizary (21 rep)
Apr 30, 2025, 08:59 AM