mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Changed way parsePEM checks with operation execute
This commit is contained in:
10
src/pass.js
10
src/pass.js
@@ -643,7 +643,7 @@ class Pass {
|
|||||||
.then(contents => {
|
.then(contents => {
|
||||||
contents.forEach((file, index) => {
|
contents.forEach((file, index) => {
|
||||||
let certName = optCertsNames[index];
|
let certName = optCertsNames[index];
|
||||||
let pem = parsePEM(file, this.Certificates._raw[certName].passphrase);
|
let pem = parsePEM(certName, file, this.Certificates._raw[certName].passphrase);
|
||||||
|
|
||||||
if (!pem) {
|
if (!pem) {
|
||||||
throw new Error(formatError("INVALID_CERTS", optCertsNames[index]));
|
throw new Error(formatError("INVALID_CERTS", optCertsNames[index]));
|
||||||
@@ -682,13 +682,11 @@ class Pass {
|
|||||||
* @returns {Object} The parsed certificate or key in node forge format
|
* @returns {Object} The parsed certificate or key in node forge format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function parsePEM(element, passphrase) {
|
function parsePEM(pemName, element, passphrase) {
|
||||||
if (element.includes("PRIVATE KEY") && passphrase) {
|
if (pemName === "signerKey" && passphrase) {
|
||||||
return forge.pki.decryptRsaPrivateKey(element, String(passphrase));
|
return forge.pki.decryptRsaPrivateKey(element, String(passphrase));
|
||||||
} else if (element.includes("CERTIFICATE")) {
|
|
||||||
return forge.pki.certificateFromPem(element);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return forge.pki.certificateFromPem(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user