Getting Data In

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

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
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!