Thread: SSL certificate location

SSL certificate location

From
Terence Ferraro
Date:
I'm not sure if this may be of any utility value to anyone else, but, the attached patch enables an environment variable to be provided to libpq to specify where to find the SSL certificate/key files used for a secure connection.

At the moment, if a user has multiple applications on a single machine connecting with different SSL certificates, each process must be launched by a different logical user and the certificates placed within that user's home directory (and this is just for *nix, forget about Windows). The current method is not scalable, either.

With the attached patch, the user just sets the environment variable e.g.

PGSQL_SSL_PATH=/home/test/cert_directory/app_1/ /usr/local/pgsql/bin/psql -U postgres -h 127.0.0.1 -p 5432
PGSQL_SSL_PATH=/home/test/cert_directory/app_2/ /usr/local/pgsql/bin/psql -U postgres -h 127.0.0.1 -p 5433

It follows the same existing conventions by looking for the actual certificates within the .postgresql sub-directory of the provided path.

Terence J. Ferraro
Attachment

Re: SSL certificate location

From
Christoph Moench-Tegeder
Date:
## Terence Ferraro (terencejferraro@gmail.com):

> At the moment, if a user has multiple applications on a single machine
> connecting with different SSL certificates, each process must be launched
> by a different logical user and the certificates placed within that user's
> home directory (and this is just for *nix, forget about Windows). The
> current method is not scalable, either.

That is incorrect.
http://www.postgresql.org/docs/current/static/libpq-ssl.html
http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS
http://www.postgresql.org/docs/current/static/libpq-envars.html

Connection parameters are "sslcert" and "sslkey", environment variables
"PGSSLCERT" and "PGSSLKEY".
You can also specify parameters in your .pg_service.conf.

Regards,
Christoph

-- 
Spare Space