2017-05-08 7 views
0

配備されたbluemixアプリケーションからCompose MongoDBサービスに接続できません。必要な証明書が見つからないようです。私はそれが環境変数VCAP_SERVICESから直接取り上げると予想していました。Bluemixのmongodbに接続できませんでした。証明書パスを見つけることができませんでした。

Javaの適切なキーストアにキーをインポートしたため、ローカルのテスト環境からこの問題を解決できます。

bluemixのnode.jsサンプルを見ると、実際に接続中に証明書を渡しています。しかし、私はJava APIのどこにもこれを見つけることができません。

私は、この証明書をbluemixのVMに追加する必要があると思われます(そうは思われません)。または、私ができないときにJavaドライバを使って渡す必要があります。

思考?レコードの

、これは私が手例外です:

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches 
ReadPreferenceServerSelector{readPreference=primary}. Client view of 
cluster state is {type=UNKNOWN, servers=[{address=bluemix-sandbox-dal-9-portal.7.dblayer.com:26123, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, 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}, caused by {sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target}, caused by {sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target}}, {address=bluemix-sandbox-dal-9-portal.6.dblayer.com:26123, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, 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}, caused by {sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target}, caused by {sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target}}] 
com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:377) 
com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104) 
com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) 
com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) 
com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63) 
com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:402) 
com.mongodb.operation.FindOperation.execute(FindOperation.java:510) 
com.mongodb.operation.FindOperation.execute(FindOperation.java:81) 
com.mongodb.Mongo.execute(Mongo.java:836) 
com.mongodb.Mongo$2.execute(Mongo.java:823) 
com.mongodb.FindIterableImpl$FindOperationIterable.first(FindIterableImpl.java:216) 
com.mongodb.FindIterableImpl.first(FindIterableImpl.java:156) 
com.ibm.smarts.experiment.UserMgr.getUserDetails(UserMgr.java:146) 
com.ibm.smarts.experiment.UserMgr.authenticateUser(UserMgr.java:123) 
com.ibm.smarts.experiment.servlet.LoginServlet.doPost(LoginServlet.java:31) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:648) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
+0

リバティは、Java buildpackのために生成する必要がありますMongoDBのデータソースとキーストアを持つあなたのためのserver.xml。 VCAP_SERVICESを解析してJavaクライアントを自分で初期化するのではなく、その方法で接続できますか? – opiethehokie

+0

私は自由よりもむしろtomcatを使用しています。同じようなserver.xmlファイルがありますか? – DungeonTiger

+0

ローカルマシンからVCAPを解析することで接続できます。私はファームブルーイムスを取得します。私はそれをローカルのJavaキーストーンに追加しました。 – DungeonTiger

答えて

1

hereを文書化し、いくつかのオプションがあります。例:

証明書をJavaトラストストアファイルにインポートし、ファイルをJavaアプリケーションにパックし、JAVA_OPTS環境変数を使用してそのパスを指定します。トラストストアファイルをリソースディレクトリの下に置くことができます。これは、単一のアプリケーションに使用することができます。

'CF設定-ENV' コマンドを使用することにより:

cf set-env <app> JAVA_OPTS '-Djavax.net.ssl.TrustStore=classpath:resources/config/truststore' 

manifest.ymlを使用することにより:

--- 
applications: 
- name: java-app 
    ... 
    env: 
    JAVA_OPTS: '-Djavax.net.ssl.TrustStore=classpath:resources/config/truststore' 
+0

これは有望そうです。私はそれを試み、報告する。 – DungeonTiger

+0

私はこれを動作させることができないと私は実際にそれをどのようにデバッグするか分からない。 最初の質問は、それがTrustStoreかtrustStoreかどうかです。私は両方を試みた。 これは私がマニフェストに持っているものです。 '用途: - パス:​​ターゲット/ RecommenderExperiment.war .... buildpack:java_buildpack ENV: JAVA_OPTS:「-Djavax.net.ssl.trustStore =クラスパス:/resources/cacert -Djavax.net.ssl.trustStorePassword = changeit'' 私は戦争のファイル構造にこれがあります: 'target \ WEB-INF \ classes \ cacerts' 私はまた 'resources'なしで試しましたパス。 何が間違っているか把握するにはどうすればよいですか? – DungeonTiger

+0

問題を再現できるように最小限の例を作成できますか? –

関連する問題