Thread: JDBC connection to postgres via SSL

JDBC connection to postgres via SSL

From
"Mark Borins"
Date:

I have downloaded and compiled with SSL support Postgres 7.4.3.

I have enabled SSL connections in both the pg_hba.conf and postgresql.conf.

 

I have been able to connect via ssl to the database from a client using pgAdmin III without any problem.

 

However, from the same client my JDBC application cannot connect to the postgres server over SSL.

What do I have to do to enable this?

I have tried putting SSL=true as a query string parameter in my connection URL.  This causes an exception about not getting a proper SSL handshake, or something of the sort.

 

So my question is, what do I have to do to be able to connect to a postgres server via SSL from JDBC?

 

Thank you

Re: JDBC connection to postgres via SSL

From
Kris Jurka
Date:

On Fri, 25 Jun 2004, Mark Borins wrote:

> I have been able to connect via ssl to the database from a client using
> pgAdmin III without any problem.
>
> However, from the same client my JDBC application cannot connect to the
> postgres server over SSL.

The libpq client doesn't need the client to recognize the server cert,
Java's default ssl connections do.  See the following message on how to
import the cert into your java keystore:

http://archives.postgresql.org/pgsql-jdbc/2003-08/msg00110.php

Kris Jurka