Changed the way in which certificates are valid; Removed async parallel execution after handlers removal; Changed model extension adding condition

This commit is contained in:
alexandercerutti
2018-07-24 01:02:54 +02:00
parent 2d66e14f15
commit 751e799462

View File

@@ -415,18 +415,12 @@ class Pass {
}); });
} }
this.model = path.resolve(options.model) + (!path.extname(options.model) ? ".pass" : ""); this.model = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : "");
let certPaths = Object.keys(options.certificates) let certPaths = Object.keys(options.certificates)
.filter(v => v !== "dir") .filter(v => v !== "dir")
.map((val) => .map((val) => path.resolve(typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"]));
path.resolve(
typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"]
)
);
async.parallel([
certsParseCallback => {
async.concat(certPaths, fs.readFile, (err, contents) => { async.concat(certPaths, fs.readFile, (err, contents) => {
if (err) { if (err) {
return reject(err); return reject(err);
@@ -434,7 +428,7 @@ class Pass {
contents.forEach(file => { contents.forEach(file => {
let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase); let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase);
if (!pem.key || !pem.value) { if (!pem) {
return reject({ return reject({
status: false, status: false,
error: { error: {
@@ -447,10 +441,6 @@ class Pass {
this.Certificates[pem.key] = pem.value; this.Certificates[pem.key] = pem.value;
}); });
return certsParseCallback();
});
},
return success(); return success();
}); });
}); });
@@ -469,7 +459,7 @@ class Pass {
value: forge.pki.certificateFromPem(element) value: forge.pki.certificateFromPem(element)
}; };
} else { } else {
return { key: null, value: null }; return {};
} }
} }
} }