Fixed certificate creation bug

Ylian Saint-Hilaire committed Sep 1, 2018 at 13:00 UTC 8bf307ec9887d8cd1320a6466a5b469fa9a849b6
2 files changed +8 -8
certoperations.js
+7 -7
@@ -33,7 +33,7 @@ module.exports.CertificateOperations = function () {
33
34 // Create a self-signed certificate
35 obj.GenerateRootCertificate = function (addThumbPrintToName, commonName, country, organization, strong) {
36 - var keys = obj.pki.rsa.generateKeyPair((strong === true) ? 3072 : 2048);
36 + var keys = obj.pki.rsa.generateKeyPair((strong == true) ? 3072 : 2048);
37 var cert = obj.pki.createCertificate();
38 cert.publicKey = keys.publicKey;
39 cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1));
@@ -42,8 +42,8 @@ module.exports.CertificateOperations = function () {
42 cert.validity.notAfter = new Date();
43 cert.validity.notAfter.setFullYear(cert.validity.notAfter.getFullYear() + 30);
44 if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: "hex" }).substring(0, 6); }
45 - if (country === undefined) { country = "unknown"; }
46 - if (organization === undefined) { organization = "unknown"; }
45 + if (country == null) { country = "unknown"; }
46 + if (organization == null) { organization = "unknown"; }
47 var attrs = [{ name: "commonName", value: commonName }, { name: "organizationName", value: organization }, { name: "countryName", value: country }];
48 cert.setSubject(attrs);
49 cert.setIssuer(attrs);
@@ -56,7 +56,7 @@ module.exports.CertificateOperations = function () {
56
57 // Issue a certificate from a root
58 obj.IssueWebServerCertificate = function (rootcert, addThumbPrintToName, commonName, country, organization, extKeyUsage, strong) {
59 - var keys = obj.pki.rsa.generateKeyPair((strong === true) ? 3072 : 2048);
59 + var keys = obj.pki.rsa.generateKeyPair((strong == true) ? 3072 : 2048);
60 var cert = obj.pki.createCertificate();
61 cert.publicKey = keys.publicKey;
62 cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1));
@@ -66,8 +66,8 @@ module.exports.CertificateOperations = function () {
66 cert.validity.notAfter.setFullYear(cert.validity.notAfter.getFullYear() + 30);
67 if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: "hex" }).substring(0, 6); }
68 var attrs = [{ name: "commonName", value: commonName }];
69 - if (country != undefined) { attrs.push({ name: "countryName", value: country }); }
70 - if (organization != undefined) { attrs.push({ name: "organizationName", value: organization }); }
69 + if (country != null) { attrs.push({ name: "countryName", value: country }); }
70 + if (organization != null) { attrs.push({ name: "organizationName", value: organization }); }
71 cert.setSubject(attrs);
72 cert.setIssuer(rootcert.cert.subject.attributes);
73
@@ -268,7 +268,7 @@ module.exports.CertificateOperations = function () {
268 }
269
270 var rootCertAndKey, rootCertificate, rootPrivateKey, rootName;
271 - if (r.root === undefined) {
271 + if (r.root == null) {
272 // If the root certificate does not exist, create one
273 console.log("Generating root certificate...");
274 rootCertAndKey = obj.GenerateRootCertificate(true, "MeshCentralRoot", null, null, strongCertificate);
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.1.9-z",
3 + "version": "0.2.0-a",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",