作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法将我的 spring-boot-app(v1.5.7)连接到我的 mongodb-server(带有 ssl 的 localhost(Win7_x64);v.3.4.6;自签名;没有 ssl 的登录正在工作)。
RoboT3 可以毫无问题地连接到我的 mongodb。
我遵循了几种解决方案,这是我尝试过的最后一个没有成功的解决方案:
将此添加到我的主类中:
@Bean
public MongoClientOptions mongoClientOptions() {
System.setProperty("javax.net.ssl.trustStore","ssl/keystore/mongoStore.ts");
System.setProperty("javax.net.ssl.trustStorePassword","123456");
System.setProperty ("javax.net.ssl.keyStore","ssl/keystore/mongoClientKeyCert.jks");
System.setProperty ("javax.net.ssl.keyStorePassword","123456");
MongoClientOptions.Builder builder = MongoClientOptions.builder();
MongoClientOptions options = builder.sslEnabled(true).sslInvalidHostNameAllowed(true).build();
return options;
}
com.mongodb.MongoSocketReadException: Exception receiving message
at com.mongodb.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:483)
at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:228)
at com.mongodb.connection.CommandHelper.receiveReply(CommandHelper.java:134)
at com.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:121)
at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:85)
at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:45)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:116)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at sun.security.ssl.AppInputStream.read(Unknown Source)
at com.mongodb.connection.SocketStream.read(SocketStream.java:85)
at com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:494)
at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:224)
... 8 common frames omitted
SSL peer certificate validation failed: self signed certificate
.\mongod.exe --dbpath .\db --auth -sslMode requireSSL --sslAllowConnectionsWithoutCertificates --sslPEMKeyFile .\ssl\server\server.pem --sslCAFile .\ssl\ca\ca.pem
最佳答案
我们遇到了类似的问题,这就是我们所做的:
keytool -import -alias clusterkey -file ./path_to_your_crt.crt -keystore mongostore -storetype pkcs12 -storepass your_password -noprompt
openssl pkcs12 -passout pass:your_password -export -out ./output_key_path.pkcs12 -in ./path_to_your_pem.pem
keytool -importkeystore -srckeystore ./output_key_path.pkcs12 -srcstoretype PKCS12 -destkeystore mongoclient -deststoretype pkcs12 -srcstorepass your_password -deststorepass your_password -noprompt
在内部,我像您一样配置了 bean
关于java - Spring Boot 使用 ssl 连接到 mongodb(对等证书验证失败),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46988077/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!