From 3223e1c2730156cd057722debd1c1cdbe8ee6d61 Mon Sep 17 00:00:00 2001 From: Christian Kvalheim Date: Thu, 26 Mar 2015 15:19:10 +0100 Subject: [PATCH] Added an ssl test for turning off sslValidation --- test/functional/ssl_mongoclient_tests.js | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/functional/ssl_mongoclient_tests.js b/test/functional/ssl_mongoclient_tests.js index 06a5bf76cc..0d6fec3333 100644 --- a/test/functional/ssl_mongoclient_tests.js +++ b/test/functional/ssl_mongoclient_tests.js @@ -549,3 +549,58 @@ exports['should correctly to replicaset using ssl connect with password'] = { } } +/** + * @ignore + */ +exports['should correctly connect using ssl with sslValidation turned off'] = { + metadata: { requires: { topology: 'ssl' } }, + + // The actual test we wish to run + test: function(configuration, test) { + var ReplSetManager = require('mongodb-tools').ReplSetManager + , MongoClient = configuration.require.MongoClient; + + // All inserted docs + var docs = []; + var errs = []; + var insertDocs = []; + + // Read the ca + var ca = [fs.readFileSync(__dirname + "/ssl/ca.pem")]; + var cert = fs.readFileSync(__dirname + "/ssl/client.pem"); + var key = fs.readFileSync(__dirname + "/ssl/client.pem"); + + var replicasetManager = new ReplSetManager({ + host: "server" + , sslOnNormalPorts: null + , sslPEMKeyFile: __dirname + "/ssl/server.pem" + , secondaries:2 + // EnsureUp options + , ssl: true + , rejectUnauthorized:false + , ca:ca + }); + + replicasetManager.start({kill: true, purge:true, signal: -9}, function(err, result) { + if(err != null) throw err; + // Connect and validate the server certificate + MongoClient.connect("mongodb://server:31000/test?ssl=true&replicaSet=rs&maxPoolSize=1", { + replSet: { + ssl:true + , sslValidate:false + } + }, function(err, db) { + test.equal(null, err); + test.ok(db != null); + + db.close(); + + // replicasetManager.stop(function() { + test.done(); + // }); + }); + }); + } +} + +