Forum Discussion

saradhipb's avatar
saradhipb
Occasional Contributor
8 years ago
Solved

SCRAM-SHA-1 mongodb authentication using SOAP UI grrovy

I am trying to write a script for connecting mongodb on the server using groovy, MongoDB uses 'SCRAM-SHA-1' auth mechanism, application is in SSL mode. I have imported key strokes in VM options file, SSL settings in preference. Code is executable in eclipse successfully but failing in ReadyAPI.

 

getting following error

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=xx.xx.xx.xx, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present}, caused by {java.security.cert.CertificateException: No subject alternative names present}}] error at line: 28.

 

Any suggestions.

  • Finally I got a solution by using MongoClientOptions

    (MongoClientOptions.builder().sslEnabled(true).sslInvalidHostNameAllowed(true).build())

3 Replies

    • saradhipb's avatar
      saradhipb
      Occasional Contributor

      Hi Tanya,

       

      I was using Ready API version 1.7. Downloaded the updated version 1.8.5, I have been facing the same issue. As indicated earlier i am able to run a similar Java code in eclipse successfully.

       

      @Grab(group='com.gmongo', module='gmongo', version='1.3')

      import com.mongodb.BasicDBObject
      import com.mongodb.DB
      import com.mongodb.DBCollection
      import com.mongodb.DBCursor
      import com.mongodb.MongoClient
      import com.mongodb.MongoClientURI

      MongoClientURI uri = new MongoClientURI("mongodb://xxxxx:xxxx123@xx.xx.xx.x:27017/xxxxxdb?ssl=true&mechanism='SCRAM-SHA-1'");
      MongoClient mongoClient = new MongoClient(uri)
      DB db = mongoClient.getDB("xxxxxdb")
      DBCollection collec = db.getCollection("yyyyyy")
      BasicDBObject query = new BasicDBObject()
      DBCursor cursor = collec.find(query)
      while (cursor.hasNext()) {
      BasicDBObject test= (BasicDBObject)(cursor.next())
      log.info test
      }

      • saradhipb's avatar
        saradhipb
        Occasional Contributor

        Finally I got a solution by using MongoClientOptions

        (MongoClientOptions.builder().sslEnabled(true).sslInvalidHostNameAllowed(true).build())