From 190cd2d6bb48e63127d03f9dde070e0934f1919c Mon Sep 17 00:00:00 2001 From: MarceloLagos <4932984+MarceloLagos@users.noreply.github.com> Date: Sat, 17 Oct 2020 23:46:18 -0600 Subject: [PATCH] Update certificate.js --- backend/internal/certificate.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 707e5ec..bd3155d 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -608,13 +608,12 @@ const internalCertificate = { checkPrivateKey: (private_key) => { return tempWrite(private_key, '/tmp') .then((filepath) => { - let key_type = private_key.includes('-----BEGIN RSA') ? 'rsa' : 'ec'; - return utils.exec('openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ') - .then((result) => { - if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) { - throw new error.ValidationError('Result Validation Error: ' + result); - } - + let key_type = private_key.includes('-----BEGIN RSA') ? 'rsa' : 'ec'; + return utils.exec('openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ') + .then((result) => { + if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) { + throw new error.ValidationError('Result Validation Error: ' + result); + } fs.unlinkSync(filepath); return true; }).catch((err) => {