Skip to content

Commit b8df633

Browse files
committed
[mongodb] more fix ssl/tls usage when converting to params and more error output
1 parent f5e121a commit b8df633

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

plugins/pluginManager.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -1098,11 +1098,17 @@ var pluginManager = function pluginManager() {
10981098
var qstring = parts[1];
10991099
if (qstring && qstring.length) {
11001100
qstring = querystring.parse(qstring);
1101-
if (qstring.ssl) {
1101+
if (qstring.ssl && (qstring.ssl === true || qstring.ssl === "true")) {
11021102
ob.ssl = "";
11031103
ob.sslAllowInvalidCertificates = "";
11041104
ob.sslAllowInvalidHostnames = "";
11051105
}
1106+
if (qstring.tls && (qstring.tls === true || qstring.tls === "true")) {
1107+
ob.tls = "";
1108+
ob.tlsAllowInvalidCertificates = "";
1109+
ob.tlsAllowInvalidHostnames = "";
1110+
ob.tlsInsecure = "";
1111+
}
11061112
if (qstring.replicaSet) {
11071113
ob.host = qstring.replicaSet + "/" + ob.host;
11081114
}
@@ -1125,11 +1131,17 @@ var pluginManager = function pluginManager() {
11251131
else {
11261132
ob.host = (config.mongodb.host + ':' + config.mongodb.port);
11271133
}
1128-
if (config.mongodb.serverOptions && config.mongodb.serverOptions.ssl) {
1134+
if (config.mongodb.serverOptions && config.mongodb.serverOptions.ssl && (config.mongodb.serverOptions.ssl === true || config.mongodb.serverOptions.ssl === "true")) {
11291135
ob.ssl = "";
11301136
ob.sslAllowInvalidCertificates = "";
11311137
ob.sslAllowInvalidHostnames = "";
11321138
}
1139+
if (config.mongodb.serverOptions && config.mongodb.serverOptions.tls && (config.mongodb.serverOptions.tls === true || config.mongodb.serverOptions.tls === "true")) {
1140+
ob.tls = "";
1141+
ob.tlsAllowInvalidCertificates = "";
1142+
ob.tlsAllowInvalidHostnames = "";
1143+
ob.tlsInsecure = "";
1144+
}
11331145
if (config.mongodb.username && config.mongodb.password) {
11341146
ob.username = config.mongodb.username;
11351147
ob.password = utils.decrypt(config.mongodb.password);
@@ -1307,6 +1319,11 @@ var pluginManager = function pluginManager() {
13071319
}
13081320
catch (ex) {
13091321
logDbRead.e("Error connecting to database", ex);
1322+
logDbRead.e("With params %j", {
1323+
db: db_name,
1324+
connection: dbName,
1325+
options: dbOptions
1326+
});
13101327
//exit to retry to reconnect on restart
13111328
process.exit(1);
13121329
return;

0 commit comments

Comments
 (0)