Mitch
Mitch

Reputation: 2400

Resolving "ssl handshake failure" error in PostgresQL

I would like to connect to my Postgres 8.3 database using SSL from my XP client using OpenSSL. This works fine without SSL. When I try it with SSL (no client certificate), I get the error:

error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure

I suspect that I need to change something with the Postgres configuration but I don't know what. I have followed the instructions in the Postgres manual for SSL including creating a self-signed certificate. In my pg_hba.conf there is a line:

host  dbname  loginname   123.45.67.89/32  md5

Is there something else I should be looking at?

Upvotes: 2

Views: 3841

Answers (2)

Steve Bonds
Steve Bonds

Reputation: 321

Postgres requires starttls. Try this instead:

echo "" | openssl s_client -starttls postgres -connect <host>:5432 -showcerts

Or with decoding of the returned certs:

echo "" | openssl s_client -starttls postgres -connect <host>:5432 -showcerts | openssl x509 -noout -text

(Answer added to this ancient question since Google was returning it as a high result for a similar problem.)

Upvotes: 0

Magnus Hagander
Magnus Hagander

Reputation: 25138

This is an error inside OpenSSL. It doesn't sound like a PostgreSQL configuration problem. However, it could be an OpenSSL config problem - check if you have any non-detailt openssl.conf on the machine(s).

Also, what version of OpenSSL do you have on the server, and what OS is that? If you have a really old one, that could be the reason.

Upvotes: 1

Related Questions