Ssl – Resolving “ssl handshake failure” error in PostgresQL

opensslpostgresqlssl

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 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

The version of OpenSSL on the server is 0.9.8g and on the client is 0.9.8j. I'd appreciate any suggestions for tracking down the problem.

Edit:

The uncommented lines from postgresql.conf are:

data_directory = '/var/ebs0/postgres/main' 
hba_file = '/etc/postgresql/8.3/main/pg_hba.conf' 
ident_file = '/etc/postgresql/8.3/main/pg_ident.conf' 
external_pid_file = '/var/run/postgresql/8.3-main.pid' 
listen_addresses = '*' 
port = 5432 max_connections = 100 
unix_socket_directory = '/var/run/postgresql' 
ssl = true 
shared_buffers = 24MB

Best Answer

My guess is that you're trying to talk ssl to a connection that isn't expecting it. You might try using hostssl, rather than host, but it would be more useful for you to show your postgresql.conf file, which should have your SSL config options in.