pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rsmogura <rsmogura@softperience.eu>
To: David Patricola <david.patricola@jefferson.edu>
Cc: Maciek Sakrejda <msakrejda@truviso.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: SSL connection failure
Date: Mon, 04 Apr 2011 12:19:28 +0200
Message-ID: <5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu> (raw)
In-Reply-To: <6F9D7504880644F289BE17E6622586A4@tjumst.jefferson.edu>
References: <84F8D58F47EF4FCFA1B34C6B12889268@tjumst.jefferson.edu>
	<AANLkTimaGkTQeYmh1rivQD+mmh78onvkj6XydYsZCFFa@mail.gmail.com>
	<6F9D7504880644F289BE17E6622586A4@tjumst.jefferson.edu>

 On Thu, 31 Mar 2011 11:36:34 -0400, David Patricola wrote:
> I got a much better error message finally!  ColdFusion's debug output
> provided me with a much better message.  The lines that say "unable 
> to find
> valid certification path to requested target" are the biggest help, 
> but I'm
> importing server.crt into the default cacerts file under
> E:\Jrun4\jre\lib\security, so is there some configuration I'm 
> missing?
>
>
> 
> ===========================================================================
> org.postgresql.util.PSQLException: The connection attempt failed.
> 	at
> 
> org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFa
> ctoryImpl.java:136)
> 	at
> 
> org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:
> 65)
> 	at
> 
> org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.
> java:116)
> 	at
> 
> org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.
> java:30)
> 	at
> org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
> 	at org.postgresql.Driver.makeConnection(Driver.java:369)
> 	at org.postgresql.Driver.connect(Driver.java:245)
> 	at
> 
> coldfusion.server.j2ee.sql.pool.JDBCPool.createPhysicalConnection(JDBCPool.j
> ava:589)
> 	at
> 
> coldfusion.server.j2ee.sql.pool.ConnectionRunner$RunnableConnection.run(Conn
> ectionRunner.java:67)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: javax.net.ssl.SSLHandshakeException:
> sun.security.validator.ValidatorException: PKIX path building failed:
> sun.security.provider.certpath.SunCertPathBuilderException: unable to 
> find
> valid certification path to requested target
> 	at
> com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
> 	at
> 
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1591)
> 	at
> com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
> 	at
> com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
> 	at
> 
> com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandsh
> aker.java:975)
> 	at
> 
> com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshake
> r.java:123)
> 	at
> 
> com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
> 	at
> 
> com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
> 	at
> 
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884
> )
> 	at
> 
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocket
> Impl.java:1096)
> 	at
> 
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:62
> 3)
> 	at
> 
> com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
> 	at
> 
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
> 	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
> 	at org.postgresql.core.PGStream.flush(PGStream.java:532)
> 	at
> 
> org.postgresql.core.v3.ConnectionFactoryImpl.sendStartupPacket(ConnectionFac
> toryImpl.java:243)
> 	at
> 
> org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFa
> ctoryImpl.java:91)
> 	... 9 more
> Caused by: sun.security.validator.ValidatorException: PKIX path 
> building
> failed: sun.security.provider.certpath.SunCertPathBuilderException: 
> unable
> to find valid certification path to requested target
> 	at
> sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
> 	at
> 
> sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
> 	at sun.security.validator.Validator.validate(Validator.java:218)
> 	at
> 
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerI
> mpl.java:126)
> 	at
> 
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509Tru
> stManagerImpl.java:209)
> 	at
> 
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509Tru
> stManagerImpl.java:249)
> 	at
> 
> com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandsh
> aker.java:954)
> 	... 21 more
> Caused by: 
> sun.security.provider.certpath.SunCertPathBuilderException:
> unable to find valid certification path to requested target
> 	at
> 
> sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBui
> lder.java:174)
> 	at
> java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
> 	at
> sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
> 	... 27 more
>
> -----Original Message-----
> From: Maciek Sakrejda [mailto:msakrejda@truviso.com]
> Sent: Wednesday, March 30, 2011 4:55 PM
> To: David Patricola
> Cc: pgsql-jdbc@postgresql.org
> Subject: Re: [JDBC] SSL connection failure
>
>> After restarting java services, I retest the datasource connection
>> (jdbc:postgresql://x.x.x.x/main?ssl) and get the fail message
>> "org.postgresql.util.PSQLException: The connection attempt failed." 
>> with
> no
>> details in any logs to provide details.  The connection works 
>> without ssl
>> fine.
>
> In addition to Dave's suggetion, have you configured driver-level
> logging to check what's going on there? See loglevel connection
> parameter and DriverManager.setLogWriter().
>
> ---
> Maciek Sakrejda | System Architect | Truviso
>
> 1065 E. Hillsdale Blvd., Suite 215
> Foster City, CA 94404
> (650) 242-3500 Main
> www.truviso.com

 Hi,

 I think it's not PG JDBC driver problem, I found such URL parameter 
 that may help sslfactory=org.postgresql.ssl.NonValidatingFactory (if it 
 doesn't changed), but in addition I would like to give You some other 
 hints:
 1. If You run driver in server environment then system keystore may not 
 be enough. Actually, common servers like Tomcat, or Glassfish provides 
 its own keystore and castore located somewhere in server directory, much 
 more this store may not be standard, desktop JKS keystore, but NSS 
 keystore, and importing certs there requires other tools.
 2. You need to put certificate as trusted, and/or if certificate has 
 parent(s), then all those should be trusted, too.
 3. Sometimes You need to provide keystore/truststore password by adding 
 -D system property to JVM launch path, not all servers gives ability to 
 open keystore by using SSL sockets.

 Regards,
 Radosław Smogura
 http://softperience.eu




view thread (8+ messages)  latest in thread

Message-ID: <5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu>
Permalink:  ../5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu/
Also on:    postgresql.org/message-id/5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu

 · 

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: rsmogura@softperience.eu, david.patricola@jefferson.edu, msakrejda@truviso.com
  Subject: Re: SSL connection failure
  In-Reply-To: <5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu>
  References: <84F8D58F47EF4FCFA1B34C6B12889268@tjumst.jefferson.edu> <AANLkTimaGkTQeYmh1rivQD+mmh78onvkj6XydYsZCFFa@mail.gmail.com> <6F9D7504880644F289BE17E6622586A4@tjumst.jefferson.edu> <5cd471cb27cc27bb33b36e1ab0723486@mail.softperience.eu>

* 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