|
|
Sponsor |
SSL for JDBC: msg#00268db.postgresql.jdbc
Hi I try to connect to postgresql server by SSL via JDBC. But I got always error. The handshake always fail. I create the SSL Private key 'server.key' and selfsigned certificate 'server.crt' by openssl. and configure postgresql to accept ssl. When I connect by psql like #psql -h 192.168.1.20 TestDB -u ---Outpot--------- psql: Warning: The -u option is deprecated. Use -U. User name: testuser Password:testpass Welcome to psql, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit SSL connection (cipher: DES-CBC3-SHA, bits: 168) ---------------------- So SSL connection is correctly setup in the postgresql server. Then, I modified the postgresql Driver, PG_Stream.java and replcace the Socket by SSLSocket as following. ++++++++++++++++++++++++++++ //connection = new Socket(host, port); SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); connection = (SSLSocket) factory.createSocket(host,port); connection.startHandshake(); ~~ //private Socket connection private SSLSocket connection; +++++++++++++++++++++++++ Than I add the certificate into the root CA to be trusted. keytool -import -storetype jks -keystore cacerts -file server.crt cacerts is in java_home/jre/lib/security/cacerts. But I still got the error. -->Exception: The connection attempt failed because Exception: javax.net.ssl.SSL Exception: Unrecognized SSL handshake. Stack Trace: javax.net.ssl.SSLException: Unrecognized SSL handshake. at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA6275) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275) at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275) at java.io.OutputStream.write(OutputStream.java:58) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275) at org.postgresql.PG_Stream.<init>(PG_Stream.java:32) at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJ dbc1Connection.java:160) at org.postgresql.Driver.connect(Driver.java:122) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at test.connectdb(test.java:47) I am wondering if anybody have successfuly connected from JDBC to PostgreSQL by SSL. Please help me! Hopefully, SSL supported driver is coming soon! Thank you. Tak ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: pg73jdbc3.jar ClassNotFoundException, Shannon Scott |
|---|---|
| Next by Date: | Re: I can't insert the chinese words., Barry Lind |
| Previous by Thread: | [Fwd: Re: pg73jdbc3.jar ClassNotFoundException], Daniel Serodio |
| Next by Thread: | Re: SSL for JDBC, Barry Lind |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|