Ask a Question

Connect to remote mongodb server with ssl - soup ui (using groovy script)

Frequent Visitor

Connect to remote mongodb server with ssl - soup ui (using groovy script)

hello everyone!
I'm trying to connect to my mongoDB database thorugh soup ui - using connection string in groovy\java
my mongodb is with ssl and authMechanism PLAIN (LDAP).
I tried to establish a string connection by so far had no luck -  I'm using the same code as I used to established a connection using eclipse (in ecplise my code work)
but when trying to connect using soup ui (groovy scripting) I got two types of error - one about ssl problem (ssl.handshakeException - unable to find valid certification path)
and one about the authSource=$external"  ($external not defined- in eclipse i don't have that issue or a problem connect to mongo with user authSource=$external")
i have those mongo driver on soup ui:

SSL has created through truststore.jks and yourpkcs.p12 and work when established  connection through eclipse

is there any one who have succeeded in create a connection to remote mongodb server with ssl and LDAP?
or anyone who can help me solve the $external problem ?

code use: 

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientSettings;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.client.MongoDatabase;
import com.mongodb.MongoException;

String user = "user";
String pass = "pass";

try {
MongoClientURI uri = new MongoClientURI("mongodb://" +user +":" +pass + "@host:port/DBname?authMechanism=PLAIN&ssl=true&authSource=$external");
MongoClient mongoClient = new MongoClient(uri);"ok");
DB db = mongoClient.getDB("NameDB");
DBCollection collec = db.getCollection("CollecDB");
BasicDBObject query = new BasicDBObject();
BasicDBObject objectArray= new BasicDBObject();
DBCursor cursor = collec.find(query);
int temp =0;
while (cursor.hasNext() && temp <1) {
objectArray= (BasicDBObject)(;

//only print the first object in db
catch (UnknownHostException e) {


public static void SetSSL()

//System.setProperty("", trustStore);
System.setProperty("", "c:\\desktop\\truststore.jks");
System.setProperty("", "test");
//System.setProperty ("",storeKey);
System.setProperty ("","c:\\desktop\\YOURPKCS.p12");
System.setProperty ("","test");

Showing results for 
Search instead for 
Did you mean: