Contributions
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 theauthSource=$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: mongodb-driver-3.8.2 mongo-java-driver-3.4.2 mongodb_unityjdbc_full 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"; SetSSL(); try { MongoClientURI uri = new MongoClientURI("mongodb://" +user +":" +pass + "@host:port/DBname?authMechanism=PLAIN&ssl=true&authSource=$external"); MongoClient mongoClient = new MongoClient(uri); log.info("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)(cursor.next()); log.info(objectArray) //only print the first object in db } } catch (UnknownHostException e) { e.printStackTrace(); } public static void SetSSL() { //System.setProperty("javax.net.ssl.trustStore", trustStore); System.setProperty("javax.net.ssl.trustStore", "c:\\desktop\\truststore.jks"); System.setProperty("javax.net.ssl.trustStoreType","jks"); System.setProperty("javax.net.ssl.trustStorePassword", "test"); //System.setProperty ("javax.net.ssl.keyStore",storeKey); System.setProperty ("javax.net.ssl.keyStore","c:\\desktop\\YOURPKCS.p12"); System.setProperty("javax.net.ssl.keyStoreType","PKCS12"); System.setProperty ("javax.net.ssl.keyStorePassword","test"); }600Views0likes0Comments