Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1396

Java driver example with SSL glosses over required truststore steps

      If one were to take the Java example provided and run it, you'll be greeted by a ~100 line-long exception chain at runtime.

      Relevant snippet:

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

      Essentially the example glosses over the required steps to import and use a custom Java trustStore (and potentially the trustStore password) that contains the MongoDB server certificate. These steps are approximately discussed in this mongodb-user comment. (Although I believe the keystore usage may have been unnecessary - I'm not certain myself.)

      (Note: it is possible that this example could work as is, but only in the case where the user starts their MongoDB node using a certificate that's been signed by a trusted 3rd party, e.g., Verisign, which are already bundled within the default JRE. However I suspect this usage would be exceedingly rare in practice.)

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            john.morales@mongodb.com John Morales (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: