Connect to MongoDb using X509 certificate
<p>I am trying to connect to MongoDB using mongoX509. I am using mongo java driver 3.3.0 jar. In api reference I can see MongoCredential to pass subject name and authenticate but i am not able to import this in my code. When I decompile the jar I am not able to see  MongoCredential as well. </p>

<p>Am I missing any dependencies. Is there any easy way to connect to Mongodb without using MongoCredential? The details i have is server, port and certificate subject name?</p>

<p>I can post the code I am trying if anyone wants to take a look at it as well</p>

<p>Thanks in Advance</p>

<p>Code - I am using SoapUI to run this code</p>

<pre><code>import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoCredential;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

try{
    def subjectName="CN=xx,OU=xx,O=xx,C=US,ST=CA,L=xx"
    MongoCredential credential = MongoCredential.createMongoX509Credential(subjectName);
    def URI = "mongodb://server1:27017,server2:27017,server3:27017/&lt;&lt;database&gt;&gt;?replicaSet=&lt;&lt;XYZ&gt;&gt;&amp;amp;authMechanism=MONGODB-X509&amp;amp;ssl=true"
    MongoClientURI uri = new MongoClientURI(URI)
    MongoClient client = new MongoClient(uri, Arrays.asList(credential));
    DB database = client.getDB(&lt;&lt;database&gt;&gt;);
    collection = database.isAuthenticated();
    log.info collection
    }
catch (Exception e){
    log.info e
    }
</code></pre>