diff --git a/certoperations.js b/certoperations.js index 5c490b00..04867cd4 100644 --- a/certoperations.js +++ b/certoperations.js @@ -307,7 +307,7 @@ module.exports.CertificateOperations = function (parent) { var keys = obj.pki.rsa.generateKeyPair({ bits: (strong == true) ? 3072 : 2048, e: 0x10001 }); var cert = obj.pki.createCertificate(); cert.publicKey = keys.publicKey; - cert.serialNumber = require('crypto').randomBytes(4).readUInt32BE(0); + cert.serialNumber = '' + require('crypto').randomBytes(4).readUInt32BE(0); cert.validity.notBefore = new Date(2018, 0, 1); cert.validity.notAfter = new Date(2049, 11, 31); if (addThumbPrintToName === true) { commonName += '-' + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); } @@ -329,7 +329,7 @@ module.exports.CertificateOperations = function (parent) { var keys = obj.pki.rsa.generateKeyPair({ bits: (strong == true) ? 3072 : 2048, e: 0x10001 }); var cert = obj.pki.createCertificate(); cert.publicKey = keys.publicKey; - cert.serialNumber = require('crypto').randomBytes(4).readUInt32BE(0); + cert.serialNumber = '' + require('crypto').randomBytes(4).readUInt32BE(0); cert.validity.notBefore = new Date(2018, 0, 1); cert.validity.notAfter = new Date(2049, 11, 31); if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); } diff --git a/webserver.js b/webserver.js index 2efc0f47..c52c8f27 100644 --- a/webserver.js +++ b/webserver.js @@ -4662,7 +4662,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.app.use(function (req, res, next) { // Set the real IP address of the request // If a trusted reverse-proxy is sending us the remote IP address, use it. - const ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; + var ipex = '0.0.0.0'; + if (typeof req.ip == 'string') { ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; } if ( (obj.args.trustedproxy === true) || ((typeof obj.args.trustedproxy == 'object') && (obj.args.trustedproxy.indexOf(ipex) >= 0)) || @@ -4735,7 +4736,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.agentapp.use(function (req, res, next) { // Set the real IP address of the request // If a trusted reverse-proxy is sending us the remote IP address, use it. - const ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; + var ipex = '0.0.0.0'; + if (typeof req.ip == 'string') { ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; } if ( (obj.args.trustedproxy === true) || ((typeof obj.args.trustedproxy == 'object') && (obj.args.trustedproxy.indexOf(ipex) >= 0)) ||