Skip to content

Commit ffd2430

Browse files
authored
Merge pull request #666 from MarceloLagos/master
Check key for RSA header otherwise use EC, and output fix.
2 parents 5c2f13e + 190cd2d commit ffd2430

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/internal/certificate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,12 @@ const internalCertificate = {
608608
checkPrivateKey: (private_key) => {
609609
return tempWrite(private_key, '/tmp')
610610
.then((filepath) => {
611-
return utils.exec('openssl rsa -in ' + filepath + ' -check -noout')
611+
let key_type = private_key.includes('-----BEGIN RSA') ? 'rsa' : 'ec';
612+
return utils.exec('openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ')
612613
.then((result) => {
613-
if (!result.toLowerCase().includes('key ok')) {
614-
throw new error.ValidationError(result);
614+
if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) {
615+
throw new error.ValidationError('Result Validation Error: ' + result);
615616
}
616-
617617
fs.unlinkSync(filepath);
618618
return true;
619619
}).catch((err) => {

0 commit comments

Comments
 (0)