From 751e799462dbd7627fc08d2adbe03e6019d8fc14 Mon Sep 17 00:00:00 2001 From: alexandercerutti Date: Tue, 24 Jul 2018 01:02:54 +0200 Subject: [PATCH] Changed the way in which certificates are valid; Removed async parallel execution after handlers removal; Changed model extension adding condition --- index.js | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/index.js b/index.js index 331fcec..98590cd 100644 --- a/index.js +++ b/index.js @@ -415,41 +415,31 @@ 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) .filter(v => v !== "dir") - .map((val) => - path.resolve( - typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"] - ) - ); + .map((val) => path.resolve(typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"])); - async.parallel([ - certsParseCallback => { - async.concat(certPaths, fs.readFile, (err, contents) => { - if (err) { - return reject(err); - } + async.concat(certPaths, fs.readFile, (err, contents) => { + if (err) { + return reject(err); + } - contents.forEach(file => { - let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase); - if (!pem.key || !pem.value) { - return reject({ - status: false, - error: { - message: "Invalid certificates got loaded. Please provide WWDR certificates and developer signer certificate and key (with passphrase).", - ecode: 418 - } - }) + contents.forEach(file => { + let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase); + if (!pem) { + return reject({ + status: false, + error: { + message: "Invalid certificates got loaded. Please provide WWDR certificates and developer signer certificate and key (with passphrase).", + ecode: 418 } + }) + } - this.Certificates[pem.key] = pem.value; - }); - - return certsParseCallback(); - }); - }, + this.Certificates[pem.key] = pem.value; + }); return success(); }); @@ -469,7 +459,7 @@ class Pass { value: forge.pki.certificateFromPem(element) }; } else { - return { key: null, value: null }; + return {}; } } }