Getting Data In

Unable to connect to Mongodb with SSL Certificate using MongoClient in Node Js Script

JiyaKhan1
New Member

Hi Team,

 

I'm trying to connect to MongoClient using Node Js Script.

While i'm passing the same certificate what we used earlier to connect through mongoose.connect . 
==========================================================
var MongoClient = require("mongodb").MongoClient,
 f = require('util').format,
 fs = require('fs');

const options = {
  server: {
  //sslValidate:true,
sslCA:fs.readFileSync("/etc/ssl/mongo-certs/client-combined.crt"),
  sslKey:fs.readFileSync("/etc/ssl/mongo-certs/client.key"),
  sslCert:fs.readFileSync("/etc/ssl/mongo-certs/client.crt"),
  }
}
MongoClient.connect("mongodb://username:password@hostname:27017/databasename?ssl=true&authSource=admin",options,

function (err,database) {
                console.log("Not Connected");
                if (err) return console.error(err);

                console.log("We are connected");
                        });
 
===================== Can you please help on this.. Log is saying as Below ============
I'm getting Below Error 


2020-07-05T11:52:44.869+0000 I ACCESS [conn805] authenticate db: admin { authenticate: 1, user: "myassistroot", nonce: "5be2405f5a0d1eed", key: "d140b8834a2f96624991bfa9cdf911df", $db: "admin" }

Labels (1)
Tags (2)
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...