bug fixes checking ssl properties

This commit is contained in:
Noah Zalev 2021-05-01 15:56:18 -04:00
parent e21077b064
commit 791afb5035

20
db.js
View File

@ -447,9 +447,11 @@ module.exports.CreateDB = function (parent, func) {
delete connectionObject.database; delete connectionObject.database;
try { try {
if (connectinArgs.ssl.cacertpath) { connectionObject.ssl.ca = [require('fs').readFileSync(connectinArgs.ssl.cacertpath, 'utf8')]; } if (connectinArgs.ssl) {
if (connectinArgs.ssl.clientcertpath) { connectionObject.ssl.cert = [require('fs').readFileSync(connectinArgs.ssl.clientcertpath, 'utf8')]; } if (connectinArgs.ssl.cacertpath) { connectionObject.ssl.ca = [require('fs').readFileSync(connectinArgs.ssl.cacertpath, 'utf8')]; }
if (connectinArgs.ssl.clientkeypath) { connectionObject.ssl.key = [require('fs').readFileSync(connectinArgs.ssl.clientkeypath, 'utf8')]; } if (connectinArgs.ssl.clientcertpath) { connectionObject.ssl.cert = [require('fs').readFileSync(connectinArgs.ssl.clientcertpath, 'utf8')]; }
if (connectinArgs.ssl.clientkeypath) { connectionObject.ssl.key = [require('fs').readFileSync(connectinArgs.ssl.clientkeypath, 'utf8')]; }
}
} catch (ex) { } catch (ex) {
console.log('Error loading SQL Connector certificate: ' + ex); console.log('Error loading SQL Connector certificate: ' + ex);
process.exit(); process.exit();
@ -1596,11 +1598,15 @@ module.exports.CreateDB = function (parent, func) {
// SSL options different on mariadb/mysql // SSL options different on mariadb/mysql
var sslOptions = ''; var sslOptions = '';
if (obj.databaseType == 4) { if (obj.databaseType == 4) {
if (props.ssl) sslOptions = ' --ssl'; if (props.ssl) {
if (props.ssl.cacertpath) sslOptions = ' --ssl-verify-server-cert --ssl-ca=' + props.ssl.cacertpath; sslOptions = ' --ssl';
if (props.ssl.cacertpath) sslOptions = ' --ssl-verify-server-cert --ssl-ca=' + props.ssl.cacertpath;
}
} else { } else {
if (props.ssl) sslOptions = ' --ssl-mode=required'; if (props.ssl) {
if (props.ssl.cacertpath) sslOptions = ' --ssl-mode=verify_identity --ssl-ca=' + props.ssl.cacertpath; sslOptions = ' --ssl-mode=required';
if (props.ssl.cacertpath) sslOptions = ' --ssl-mode=verify_identity --ssl-ca=' + props.ssl.cacertpath;
}
} }
cmd += sslOptions; cmd += sslOptions;