Spring boot connection mongodb error Exc sending message CertificateException

the local startup project reported an error,
the same code configuration, but there is no problem with others.
solve the reason,

{"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"}

Code:

@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;
    }
}

issues related to certificates.

  1. first check whether your server is configured with a certificate;
  2. see if client certificates are mandatory;
  3. secondly, it depends on whether the certificate is self-signed or issued by a legitimate third party;

if you don't know what to think, you'd better ask the people who configure MongoDB.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be9b3d-31981.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be9b3d-31981.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?