From 791afb5035c64e6978c3843db884d1c3a39270bf Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Sat, 1 May 2021 15:56:18 -0400 Subject: [PATCH] bug fixes checking ssl properties --- db.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/db.js b/db.js index 050cd3bb..f90d70f6 100644 --- a/db.js +++ b/db.js @@ -447,9 +447,11 @@ module.exports.CreateDB = function (parent, func) { delete connectionObject.database; try { - if (connectinArgs.ssl.cacertpath) { connectionObject.ssl.ca = [require('fs').readFileSync(connectinArgs.ssl.cacertpath, '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')]; } + if (connectinArgs.ssl) { + if (connectinArgs.ssl.cacertpath) { connectionObject.ssl.ca = [require('fs').readFileSync(connectinArgs.ssl.cacertpath, '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) { console.log('Error loading SQL Connector certificate: ' + ex); process.exit(); @@ -1596,11 +1598,15 @@ module.exports.CreateDB = function (parent, func) { // SSL options different on mariadb/mysql var sslOptions = ''; if (obj.databaseType == 4) { - if (props.ssl) sslOptions = ' --ssl'; - if (props.ssl.cacertpath) sslOptions = ' --ssl-verify-server-cert --ssl-ca=' + props.ssl.cacertpath; + if (props.ssl) { + sslOptions = ' --ssl'; + if (props.ssl.cacertpath) sslOptions = ' --ssl-verify-server-cert --ssl-ca=' + props.ssl.cacertpath; + } } else { - if (props.ssl) sslOptions = ' --ssl-mode=required'; - if (props.ssl.cacertpath) sslOptions = ' --ssl-mode=verify_identity --ssl-ca=' + props.ssl.cacertpath; + if (props.ssl) { + sslOptions = ' --ssl-mode=required'; + if (props.ssl.cacertpath) sslOptions = ' --ssl-mode=verify_identity --ssl-ca=' + props.ssl.cacertpath; + } } cmd += sslOptions;