This fails with tlsv1 alert unknown ca
psql -h localhost -p 4566 -d dev -U root --set=sslmode=disable
This works:
psql "port=4566 host=localhost user=root dbname=dev sslmode=disable"
Why? Why does one work when the other does not? Is the --set
ignored?
Is this a bug or a feature?
2
Answers
The –set is not ignored, it just doesn’t do anything meaningful. It tells psql to set the psql variable named ‘sslmode’, but that variable is not in charge of anything. If you could connect and you then ran
select :'sslmode';
, you find that it had indeed been set, but since it isn’t in charge of anything this doesn’t really matter much.TheA way to do this correctly, assuming you are using bash, is:https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
The second one works. Because (sslmode=disable) is part of the connection string key words.
psql --help
returns:also if you
psql --help | grep ssl
, there is zero result. which mean you cannot use simple usepsql -h localhost -p 4566 -d dev -U root --sslmode=disable
.jjanes’s answer works because: https://www.postgresql.org/docs/current/libpq-envars.html