1) create user test with password test and database test with owner test 2) add md5 auth for this user in pg_hba.conf like host test test 172.19.0.0/16 md5 3) compile test program src/postgres/src/test/examples/testlibpq.c 4) run test program with argument "host=postgres user=test password=wrong" 5) get double error on client side:
You have described the behavior, but not what about it is buggy. This looks expected to me.
It tries to connect with encryption and fails, then tries to connect without encryption and also fails.
If you set sslmode to 'disable' or to 'require' (or higher) then you will only get one connection attempt. But if it is 'allow' or 'prefer' (the default), then you will get two.