Reputation: 11
I'm trying to connect a Spring Boot with a Mongodb Atlas, but the connection fails giving this error:
Caused by: javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative names
matching IP address xxx.xxx.xxx.xxx found
(Driver version mongodb-driver-core-3.11.2.jar)
This is my uri connection:
mongodb://XXX:YYY@xxx-00:27017,xxx-01:27017,xxx-02:27017/dbName?ssl=true&replicaSet=set-shared-0&authSource=admin
I have no problem connecting with the same uri and the same machine via nodejs
Upvotes: 1
Views: 1561
Reputation: 5354
Atlas only allows client connections to the cluster from entries in the project’s whitelist. To connect, you must add an entry to the whitelist. Perhaps, this is the reason. Where do you run your NodeJS code and Spring Boot App?
From what you provided in your question, it's quite difficult to figure out if you have done all the necessary steps Atlas Documentation requires you to do and what exactly can cause your issue.
If you need to establish a secured connection, I would recommend checking Security Features and Setup section and Configure Whitelist Entries section of the official guide, where you can find a lot of information regarding network and firewall requirements, etc. you need to meet to be able to connect using SSL.
Also, a good idea would be to try to figure out how your NodeJS App setup is different from your Spring Boot App setup. Perhaps your Spring Boot App is missing some configs, but there are not enough details to be more precise.
In some cases, you might need to disable hostname verification for Mongo.
You can try this by adding one more parameter to your URI sslInvalidHostNameAllowed
:
?ssl=true&sslInvalidHostNameAllowed=true&...
But, as I mentioned, based on your question details - those are only guesses :)
Upvotes: 1