我有一个MongoDb
实例运行(单实例)SSL
已启用。我可以通过以下方式连接到它RoboMongo
在哪里SSL
选项卡我提供以下内容:
CA File : /path to my certificate/testCA.pem
PEM certificate/key: /path to my key/testKey.pem
从而成功连接。现在我尝试从 java 应用程序连接到同一个 mongodb。我使用以下命令将测试 A.pem 导入到 cacerts 中:
keytool -import -keystore cacerts -file testCA.pem -storepass changeit
我可以看到商店中添加了一个新条目。尝试将其他密钥添加到其中,但它显示证书无效。在 Java 应用程序上,我将系统属性设置如下:
System.setProperty ("javax.net.ssl.trustStore","C:\\Program Files\\Java\\jre1.8.0_91\\lib\\security\\cacerts");
System.setProperty ("javax.net.ssl.trustStorePassword","changeit");
我收到以下错误:
org.springframework.dao.DataAccessResourceFailureException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=test.mongo.com:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.io.EOFException}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=test.mongo.com:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.io.EOFException}}]
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:75)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2075)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1918)
我在这里缺少什么,提前谢谢!