Java authentication with X509 certificate

I am trying to connect with Atlas MongoDB using X509 Certificate from Java. Before 3.6 Version of the Driver there used to be an option to use socketfactory in which we can programmatically get the certificate on the fly and put it in socketfactory.

MongoClientOptions.Builder optionBuilder = new MongoClientOptions.Builder();
optionBuilder.sslEnabled(true);
optionBuilder.socketFactory(context.getSocketFactory());

Now in 4.0 Version of Java Driver I don’t see a option to set SocketFactory in MongoClientSettings

Can you please provide some help.

You should be able to achieve the same effect with com.mongodb.MongoClientOptions.Builder#sslContext, which allows your application to set the SSLContext that is used by the driver to get the SocketFactory.