Skip to content

Commit

Permalink
bug fix uisp certs
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewiski committed Jan 17, 2023
1 parent 163c06b commit a43e37b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ var defaultConfig = {
"adminRoute": "/admin",
"logLevel": "info",
"useHttp": true,
"useHttps": false,
"useHttps": true,
"httpport": 49080,
"httpsport": 49443,
"adminUsername": "admin",
"adminPasswordHash": "01b7783d35cfcbbc957461516f337075", // UISPToolsPassword
"httpsServerKey": "/home/unms/data/cert/live.key",
"httpsServerCert": "/home/unms/data/cert/live.crt",
"unmsUrl": "http://unms:8081/nms/api/v2.1/",
"ucrmUrl": "http://uisp.example.com/crm/api/v1.0/",
"ucrmUrl": "http://ucrm:80/crm/api/v1.0/",
"ucrmAppKey": "CreateAppKeyFromUISPWebSite",
"opensslPath": "",
"maxLogLength": 500,
Expand Down Expand Up @@ -114,8 +114,6 @@ if(objOptions.httpsServerCert.startsWith("/") === true){
httpsServerCert = path.join(__dirname, configFolder, objOptions.httpsServerCert);
}


; path.join(__dirname, configFolder, objOptions.httpsServerKey)
var letsEncryptCertificateFolder = path.join(certificatesFolder, 'letsEncrypt');
if(fs.existsSync(letsEncryptCertificateFolder) === false){
fs.mkdirSync(letsEncryptCertificateFolder,{recursive:true});
Expand Down Expand Up @@ -749,7 +747,7 @@ routes.get('/*', function (req, res) {

var loadCertificates = function () {
try {
letsEncrypt.loadX509CertSync({ certFile: path.join(__dirname, configFolder, objOptions.httpsServerCert), keyFile: path.join(__dirname, configFolder, objOptions.httpsServerKey) }).then(
letsEncrypt.loadX509CertSync({ certFile: httpsServerCert, keyFile: objOptions.httpsServerKey }).then(
function (Certs) {
try {
//clean up the binary data we don't need
Expand Down Expand Up @@ -799,9 +797,9 @@ var getHttpsServerOptions = function () {

var httpsOptions = {};

if (fs.existsSync(path.join(__dirname, configFolder, objOptions.httpsServerKey)) === true && fs.existsSync(path.join(__dirname, configFolder, objOptions.httpsServerCert)) === true) {
httpsOptions.key = fs.readFileSync(path.join(__dirname, configFolder, objOptions.httpsServerKey));
httpsOptions.cert = fs.readFileSync(path.join(__dirname, configFolder, objOptions.httpsServerCert));
if (fs.existsSync(httpsServerKey) === true && fs.existsSync(httpsServerCert) === true) {
httpsOptions.key = fs.readFileSync(httpsServerKey);
httpsOptions.cert = fs.readFileSync(httpsServerCert);
} else {
logUtilHelper.log(appLogName, "app", "warning", "httpsServer certificate files missing unable to use https");
}
Expand Down

0 comments on commit a43e37b

Please sign in to comment.