This repository contains examples that demonstrate usage of MongoDB Java Driver with MongoDB database.
Package: org.mongodb.connect.tls
This package contains several examples demonstrating MongoClient configuration and establishment of TLS connectivity between the MongoDB database and MongoDB Java Driver
The code has been tested with:
mongodb-driver-sync
) v4.1.0
The following TLS connectivity use cases covered:
Certs from a known Certificate Authority are usually stored in the cacerts
file provided with the JRE. The use cases in the following examples assume the CA certificates were issued privately, and were not issued by a known Certificate Authority.
The classes implementing the use cases are separated into two packages:
org.mongodb.connect.tls.cert_store
org.mongodb.connect.tls.sslcontext
Classes in the org.mongodb.connect.tls.cert_store
demonstrate how to set the location of the certificate files by using the following JVM system properties:
javax.net.ssl.trustStore
- points to the JKS Trust Store file holding the CA certificatejavax.net.ssl.keyStore
- points to the PKCS12 Key Store file holding the Client's certificateClasses in the org.mongodb.connect.tls.sslcontext
demonstrate implementation of the same use cases, but with the MongoClient object configured to use a custom SSLContext.