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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...