javascript - How to implement a mongodb connection over https with node.js? -
i've got following code, manage sign up/login part in web application.
if want work on secured connection,(so encryption wouldn't needed far in application in mongo database?) how can add https?
var express = require ("express"); var mongodb = require ("mongodb"); var servidor = new express(); var bson = mongodb.bsonpure; servidor.use(express.static(__dirname+"/public")); servidor.use(express.bodyparser()); var cliente_mongo = mongodb.mongoclient; cliente_mongo.connect("mongodb://localhost/campusero", function (err, db) { if (err) { console.log("error de conexión "+err); } else { console.log("connected database"); } servidor.listen(8080); });
the drivers communicate using tcp/ip sockets. therefore, must enable encrypted communication via ssl. i've provided links below describing procedure (includes syntax native node.js driver). ssl have enabled in mongodb environment, , ssl options have enabled in application interfaces the driver.
http://docs.mongodb.org/manual/tutorial/configure-ssl/ http://docs.mongodb.org/manual/tutorial/configure-sslclients/
Comments
Post a Comment