我有一个MongoDb
实例正在运行(单实例),启用了SSL
。我能够与RoboMongo
连接到它那里SSL
选项卡上我提供以下信息:使用SSL从JAVA应用程序连接到MongoDb
CA File : /path to my certificate/testCA.pem
PEM certificate/key: /path to my key/testKey.pem
哪些成功连接。现在我试图从java应用程序连接到相同的mondodb。我进口testCA.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)
缺少什么我在这里先谢谢了!
我有完全一样的问题,但它仍然不是为我工作,我在Linux上运行的窗口,以便从“testKey.pem”创建xyz.pkcs12和密钥存储复制它交给窗口和进口的相同,没有任何东西否则我应该这样做? – Amit
@Amit你可以发布你的stacktrace吗? – Gurkha
javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:本 \t在sun.security.ssl.Alerts.getSSLException(未知来源) \t在sun.security.ssl.SSLSocketImpl.fatal没有使用者替代名称(未知来源) \t在sun.security.ssl.Handshaker.fatalSE(未知来源) \t在sun.security.ssl.Handshaker.fatalSE(未知来源) \t在sun.security.ssl.ClientHandshaker.serverCertificate(未知来源) \t at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) \t at sun.security.ssl.Handshaker.processLoop(Unknown Source) – Amit