Question

How to use managed mongoldb in spring boot application .

I getting tls certificate issue … Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

The Java driver supports TLS/SSL connections to MongoDB servers using the underlying support for TLS/SSL provided by the JDK.

You can achieve this by following these steps here:

https://mongodb.github.io/mongo-java-driver/3.5/driver/tutorials/ssl/

Note that your driver should be v3.5 or higher.

Best,

Bobby

Having the very same issue here with a managed monogDB Cluster from DigitalOcean and Spring data mongodb. I generated a new java keystore (as described here, for the one who seeks more details: https://mongodb.github.io/mongo-java-driver/3.5/driver/tutorials/ssl/) and imported the ca-certificate.crt provided by DigitalOcean I used this syntax:

keytool -importcert -trustcacerts -file ca-certificate.crt -keystore mykeystore -storepass mypassword```

Added system properties to the java command when starting my application:
-Djavax.net.ssl.trustStore=mykeystore
-javax.net.ssl.trustStorePassword=mypassword

Java does not complain about missing keystore or wrong password (I counter checked by provoking an error with invalid filename and password) yet still I get the error:

Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

… Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

… Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


Any help would be highly appreciated.