Fixed certificate creation problem.
Ylian Saint-Hilaire committed
Sep 23, 2020 at 09:29 UTC
c2cda23e8372a757e9a79b5a73f1500fb5a529c5
2 files changed
+6
-4
certoperations.js
+2
-2
@@ -307,7 +307,7 @@ module.exports.CertificateOperations = function (parent) {
307
var keys = obj.pki.rsa.generateKeyPair({ bits: (strong == true) ? 3072 : 2048, e: 0x10001 });
308
var cert = obj.pki.createCertificate();
309
cert.publicKey = keys.publicKey;
310
- cert.serialNumber = require('crypto').randomBytes(4).readUInt32BE(0);
310
+ cert.serialNumber = '' + require('crypto').randomBytes(4).readUInt32BE(0);
311
cert.validity.notBefore = new Date(2018, 0, 1);
312
cert.validity.notAfter = new Date(2049, 11, 31);
313
if (addThumbPrintToName === true) { commonName += '-' + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); }
@@ -329,7 +329,7 @@ module.exports.CertificateOperations = function (parent) {
329
var keys = obj.pki.rsa.generateKeyPair({ bits: (strong == true) ? 3072 : 2048, e: 0x10001 });
330
var cert = obj.pki.createCertificate();
331
cert.publicKey = keys.publicKey;
332
- cert.serialNumber = require('crypto').randomBytes(4).readUInt32BE(0);
332
+ cert.serialNumber = '' + require('crypto').randomBytes(4).readUInt32BE(0);
333
cert.validity.notBefore = new Date(2018, 0, 1);
334
cert.validity.notAfter = new Date(2049, 11, 31);
335
if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); }
webserver.js
+4
-2
@@ -4662,7 +4662,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4662
obj.app.use(function (req, res, next) {
4663
// Set the real IP address of the request
4664
// If a trusted reverse-proxy is sending us the remote IP address, use it.
4665
- const ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip;
4665
+ var ipex = '0.0.0.0';
4666
+ if (typeof req.ip == 'string') { ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; }
4667
if (
4668
(obj.args.trustedproxy === true) ||
4669
((typeof obj.args.trustedproxy == 'object') && (obj.args.trustedproxy.indexOf(ipex) >= 0)) ||
@@ -4735,7 +4736,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4736
obj.agentapp.use(function (req, res, next) {
4737
// Set the real IP address of the request
4738
// If a trusted reverse-proxy is sending us the remote IP address, use it.
4738
- const ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip;
4739
+ var ipex = '0.0.0.0';
4740
+ if (typeof req.ip == 'string') { ipex = (req.ip.startsWith('::ffff:')) ? req.ip.substring(7) : req.ip; }
4741
if (
4742
(obj.args.trustedproxy === true) ||
4743
((typeof obj.args.trustedproxy == 'object') && (obj.args.trustedproxy.indexOf(ipex) >= 0)) ||