diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 613c837c..a6495ff2 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -617,8 +617,18 @@ const internalCertificate = { fs.unlinkSync(filepath); return true; }).catch((err) => { - fs.unlinkSync(filepath); - throw new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err); + return utils.exec('openssl ec -in ' + filepath + ' -check -noout') + .then((result) => { + if (!result.toLowerCase().includes('key ok')) { + throw new error.ValidationError(result); + } + + fs.unlinkSync(filepath); + return true; + }).catch((err) => { + fs.unlinkSync(filepath); + throw new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err); + }); }); }); },