Improved passphrase extraction

This commit is contained in:
Alexander Cerutti
2020-09-05 22:33:13 +02:00
parent a441297aa2
commit f171b93977

View File

@@ -270,13 +270,12 @@ export async function readCertificatesFromOptions(options: Certificates): Promis
const parsedContents = await Promise.all(rawContentsPromises); const parsedContents = await Promise.all(rawContentsPromises);
const pemParsedContents = parsedContents.map((file, index) => { const pemParsedContents = parsedContents.map((file, index) => {
const certName = Object.keys(options)[index]; const certName = Object.keys(options)[index];
const pem = parsePEM( const passphrase = (
certName, typeof options.signerKey === "object" &&
file, options.signerKey?.passphrase
typeof options.signerKey === "object" ) || undefined;
? options.signerKey.passphrase
: undefined const pem = parsePEM(certName, file, passphrase);
);
if (!pem) { if (!pem) {
throw new Error(formatMessage("INVALID_CERTS", certName)); throw new Error(formatMessage("INVALID_CERTS", certName));