pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Angel Todorov <atodorov@acm.org>
To: pgsql-jdbc@postgresql.org
Subject: JDBC with SSL
Date: Sun, 21 Sep 2003 17:43:22 +0200
Message-ID: <3F6DC71A.7050003@acm.org> (raw)

Hello,
I have a question regarding the SSL support of  the development JDBC3 
driver. I want to connect securely to a postgresql database . My 
environment is the following:

PostgreSQL server version: PostgreSQL 7.3.2
OS on which the server is running: OpenBSD 3.3

--- from postgresql.conf ---

ssl = true

----------------------------

I have also generated the needed certificates for the SSL support as 
described in the PostgreSQL manual under" 3.7. Secure TCP/IP Connections 
with SSL".

The client enviroment is the following:
OS: Windows XP
JDK : j2sdk1.4.2_01
jdbc driver: JDBC3, development version
IDE: Eclipse

Normally, without SSL, the connectivity is O.K

When enabled, the following exception is thrown:

org.postgresql.util.PSQLException: An I/O error has occured while 
flushing the output - Exception: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: No trusted certificate found

Here is also a small part of the stack trace:
--------------------------------------------------
Caused by: sun.security.validator.ValidatorException: No trusted 
certificate found
   at sun.security.validator.SimpleValidator.buildTrustedChain(Unknown 
Source)
   at sun.security.validator.SimpleValidator.engineValidate(Unknown Source)
   at sun.security.validator.Validator.validate(Unknown Source)
   at 
com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown 
Source)
   at 
com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown 
Source)
   ... 16 more
End of Stack Trace

   at org.postgresql.core.PGStream.flush(PGStream.java:416)
   at 
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1Connection.java:284) 

   at 
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:213) 

   at org.postgresql.Driver.connect(Driver.java:138)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at PostgreSQLSSL.main(PostgreSQLSSL.java:33)
java.lang.NullPointerException
   at PostgreSQLSSL.main(PostgreSQLSSL.java:39)
Exception in thread "main"
-----------------------------------------------------

The code that generates the above Exception is :

--- START ------

   public static void main(String[] args) throws SQLException {

       Properties opt = new Properties();
             opt.setProperty("ssl", "true");
       opt.setProperty("user", username);
       opt.setProperty("password", password);

       Connection db=null;
             try {
                 Class driver=Class.forName("org.postgresql.Driver");
       db = DriverManager.getConnection(url, opt);
       } catch (Exception e) {
           e.printStackTrace();
       }
------- END ------------

I have imported the server's certificate using the keytool successfully 
, though the exception states that no *trusted* certificate is found. My 
certificate is self-signed. Could it be the problem that the certificate 
is not accepted (i.e i have to create it differently either on the 
server side, or import it differently on the client side) ? Or maybe  
there is a conflict between the PostgreSQL and JDBC3 versions?

Thanks a lot in advance for your help.

Regards,

Angel




view thread (25+ messages)  latest in thread

Message-ID: <3F6DC71A.7050003@acm.org>
Permalink:  ../3F6DC71A.7050003@acm.org/
Also on:    postgresql.org/message-id/3F6DC71A.7050003@acm.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: atodorov@acm.org
  Subject: Re: JDBC with SSL
  In-Reply-To: <3F6DC71A.7050003@acm.org>
  References: <3F6DC71A.7050003@acm.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox