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.