2012-02-21 25 views
5

私は、Spoonに付属のJDBCドライバを使用して、Heroku PostgreSQLインスタンスにスプーンを接続しようとしています。 Herokuは、私が有効にしたスタンドアローンのPostgreSQLインスタンスに対してSSLを要求しています。Pentahoケトル/スプーンとHeroku PostgreSQLをSSLで接続する際の問題

私はSSLを使用して他のクライアントソフトウェアを使用してデータベースに接続できます。これはJava/JDBCに固有のようです。私はこの問題を解決するためにJavaについて十分に分かっていないので、これまで誰かがそこにいたことを期待していました。

SSLHandshakeExceptionについて言及している次の冗長なエラーメッセージが表示されますが、これが原因であるか他の何かの症状であるかわかりません。おそらく、JavaでSSL証明書を指定する必要がありますか?

Error connecting to database [XXXX.com] : org.pentaho.di.core.exception.KettleDatabaseException: 
Error occured while trying to connect to the database 

Error connecting to database: (using class org.postgresql.Driver) 
The connection attempt failed. 


org.pentaho.di.core.exception.KettleDatabaseException: 
Error occured while trying to connect to the database 

Error connecting to database: (using class org.postgresql.Driver) 
The connection attempt failed. 


at org.pentaho.di.core.database.Database.normalConnect(Database.java:374) 
at org.pentaho.di.core.database.Database.connect(Database.java:323) 
at org.pentaho.di.core.database.Database.connect(Database.java:285) 
at org.pentaho.di.core.database.Database.connect(Database.java:275) 
at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:76) 
at org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2455) 
at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:511) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:329) 
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:139) 
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:123) 
at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:26) 
at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:119) 
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) 
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) 
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) 
at org.eclipse.jface.window.Window.open(Window.java:796) 
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:378) 
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:304) 
at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:104) 
at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:51) 
at org.pentaho.di.ui.trans.step.BaseStepDialog$3.widgetSelected(BaseStepDialog.java:480) 
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) 
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) 
at org.pentaho.di.ui.trans.steps.tableoutput.TableOutputDialog.open(TableOutputDialog.java:916) 
at org.pentaho.di.ui.spoon.delegates.SpoonStepsDelegate.editStep(SpoonStepsDelegate.java:126) 
at org.pentaho.di.ui.spoon.Spoon.editStep(Spoon.java:7733) 
at org.pentaho.di.ui.spoon.trans.TransGraph.editStep(TransGraph.java:2744) 
at org.pentaho.di.ui.spoon.trans.TransGraph.mouseDoubleClick(TransGraph.java:693) 
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) 
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) 
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) 
at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1169) 
at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:6945) 
at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:553) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:134) 
Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 
Error connecting to database: (using class org.postgresql.Driver) 
The connection attempt failed. 

at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:510) 
at org.pentaho.di.core.database.Database.normalConnect(Database.java:358) 
... 50 more 
Caused by: org.postgresql.util.PSQLException: The connection attempt failed. 
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:152) 
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) 
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125) 
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30) 
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) 
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:32) 
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24) 
at org.postgresql.Driver.makeConnection(Driver.java:393) 
at org.postgresql.Driver.connect(Driver.java:267) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:490) 
... 51 more 
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(Unknown Source) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source) 
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) 
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) 
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source) 
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source) 
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source) 
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source) 
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source) 
at java.io.BufferedOutputStream.flushBuffer(Unknown Source) 
at java.io.BufferedOutputStream.flush(Unknown Source) 
at org.postgresql.core.PGStream.flush(PGStream.java:523) 
at org.postgresql.core.v3.ConnectionFactoryImpl.sendStartupPacket(ConnectionFactoryImpl.java:259) 
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:105) 
... 62 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(Unknown Source) 
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) 
at sun.security.validator.Validator.validate(Unknown Source) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) 
... 75 more 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) 
at java.security.cert.CertPathBuilder.build(Unknown Source) 
... 81 more 

Hostname  : XXXX.com 
Port   : 5432 
Database name : XXXX 

答えて

19

は私が問題を発見しました。単に

ssl = true 

を渡すと、あなたもPgJDBCは、リモート証明書を検証できるように、Javaキーストアで正しいルート証明書をインストールする必要があり、JDBCのために十分ではありません。あなたは、ルート証明書ストアを設定しない場合は

あなたの代わりに渡していない場合がありますので、やってはman-in-the-middle攻撃防御を無効に

ssl = true 
sslfactory = org.postgresql.ssl.NonValidatingFactory 

ものの、ので、あなたのSSLセッションもはや信頼性の高いエンドツーエンドのセキュリティを備えています。

ここでHerokuのドキュメントを参照してください:

http://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#connecting_to_a_dedicated_database_remotely

(クレイグ・リンガーによって追加SSLセキュリティに関する警告)

+0

または、必要なCERTをJava SSLが検索できる適切な場所に置くことができます。 –

1

基本的な問題は、SSLハンドシェイクのようです。エラーメッセージの抜粋:

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 

これはPostgreSQL固有の問題ではなく、純粋なSSLの問題です。これらのエラーメッセージを使用して、このサイトのかなりのヘルプを見つけることができます。この答えは私には有望に見えるそれらをスキミングし、それが正しい方向にあなたを導く可能性がある:

https://stackoverflow.com/a/6908991/947357

+0

うん、これは純粋なSSLの問題です。先端に感謝します。 Javaが手動で証明書を追加する必要があることを認識していない。 –

関連する問題