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!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...