skip to Main Content

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


  1. 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:

    PGSSLMODE=disable psql -h localhost -p 4566 -d dev -U root
    
    Login or Signup to reply.
  2. 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:

      -s, --single-step        single-step mode (confirm each query)
      -S, --single-line        single-line mode (end of line terminates SQL command)
    

    also if you psql --help | grep ssl, there is zero result. which mean you cannot use simple use
    psql -h localhost -p 4566 -d dev -U root --sslmode=disable .

    jjanes’s answer works because: https://www.postgresql.org/docs/current/libpq-envars.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search