Skip to content

Commit 7ba58bd

Browse files
authored
Update certificate.js
1 parent 301499d commit 7ba58bd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

backend/internal/certificate.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +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')
612-
.then((result) => {
613-
if (!result.toLowerCase().includes('key ok')) {
614-
throw new error.ValidationError(result);
615-
}
611+
let key_type = private_key.includes('-----BEGIN RSA') ? 'rsa' : 'ec';
612+
return utils.exec('openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ')
613+
.then((result) => {
614+
if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) {
615+
throw new error.ValidationError('Result Validation Error: ' + result);
616+
}
616617

617618
fs.unlinkSync(filepath);
618619
return true;

0 commit comments

Comments
 (0)