MongoDB Atlas spring boot X.509 certificate based connection issue

I am trying to connect MongoDB from a Spring Boot application using an X.509 certificate downloaded from the MongoDB Atlas site. I have placed the .**pem** file in the resource directory. Additionally, I have added the following URI to the application.properties file:

spring.data.mongodb.uri=mongodb+srv://cluster0.uzmiipr.mongodb.net/demo?authSource=%24external&authMechanism=MONGODB-X509&ssl=true&tls=true&tlsCertificateKeyFile=classpath:CX509-cert-9188001417325818856.pem

However, when I attempt to perform any operation, I receive the following error message:

 Command failed with error 8000 (AtlasError): 'certificate validation failed' on server

I have also tried connecting to the database using a username and password, and in that case, I am able to connect and access the database successfully. I would appreciate your guidance on resolving this issue.

Hi @janarthanan_s

The Java driver doesn’t support the tlsCertificateKeyFile query parameter. You have to add the certificate to the system key store. See https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/connection/tls/#configure-the-jvm-key-store for details.

Regards,
Jeff