spring boot 连接mongodb报错 Exc sending message CertificateException
本地启动项目报错,
同样的代码配置,才别人那里没有问题,
求解什么原因,
{"exception":"com.mongodb.MongoSocketWriteException: Exception sending
messagerntat
com.mongodb.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:516)rntat
com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:404)rntat
com.mongodb.connection.InternalStreamConnection.sendCommandMessage(InternalStreamConnection.java:269)rntat
com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:252)rntat
com.mongodb.connection.CommandHelper.sendAndReceive(CommandHelper.java:84)rntat
com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:34)rntat
com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:91)rntat
com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:51)rntat
com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:127)rntat
com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114)rntat
java.lang.Thread.run(Thread.java:745)rnCaused by:
javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative names
matching IP address 18.233.195.78 foundrntat
sun.security.ssl.Alerts.getSSLException(Alerts.java:192)rntat
sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)rntat
sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)rntat
sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)rntat
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1506)rntat
sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)rntat
sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)rntat
sun.security.ssl.Handshaker.process_record(Handshaker.java:914)rntat
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)rntat
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)rntat
sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)rntat
sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)rntat
com.mongodb.connection.SocketStream.write(SocketStream.java:74)rntat
com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:401)rnt...
9 morernCaused by: java.security.cert.CertificateException: No
subject alternative names matching IP address 18.233.195.78
foundrntat
sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:167)rntat
sun.security.util.HostnameChecker.match(HostnameChecker.java:93)rntat
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)rntat
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)rntat
sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)rntat
sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)rntat
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1488)rnt...
18
morern","thread_id":46,"level":"INFO","logger_name":"org.mongodb.driver.cluster","time":"2018-05-21T10:43:27.437+08:00","message":"Exception
in monitor thread while connecting to server
cluster0-shard-00-01-ta2km.mongodb.net:27017"}
代码:
@SpringBootApplication(exclude = { SessionAutoConfiguration.class, DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,MongoAutoConfiguration.class })
public class App {
...
}
@Component
public class MongoDBHelper {
@Value("${mongoClient.uri}")
private String mongoClientUri;
@Value("${dbName}")
private String databaseName;
private static MongoClient mongoClient = null;
public MongoDBHelper() {
}
@Bean
public MongoClient getMongoClient() {
if (mongoClient == null) {
MongoClientURI uri = new MongoClientURI(mongoClientUri);
mongoClient = new MongoClient(uri);
}
return mongoClient;
}
public MongoDatabase getMongoDataBase() {
MongoDatabase database = getMongoClient().getDatabase(databaseName);
return database;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
跟证书相关的问题。
如果不清楚怎么看,最好问问你们配置MongoDB的人会比较清楚。