Postgresql – How to specify a client certificate to psql

postgresqlpsqlssl-certificate

I have a Postgres server with a user dev which requires a client certificate to log in. I'm using the command psql "sslmode=require user=dev host=db.prod", which gives me psql: FATAL: connection requires a valid client certificate.

I know where the certificate is on my server. My question is, how do I specify the client certificate location to psql?

Best Answer

The end result looks like $>psql "port=5431 host=localhost user=postgres sslcert=./test/client.crt sslkey=./test/client.key sslrootcert=./test/server.crt sslmode=verify-ca"

All the variables are here.