Check also certificate keys using elliptic curve algorithms

This commit is contained in:
Michael Koch 2020-10-17 17:20:50 +02:00
parent 301499dc52
commit 8aa2516a55

View file

@ -609,6 +609,15 @@ const internalCertificate = {
return tempWrite(private_key, '/tmp') return tempWrite(private_key, '/tmp')
.then((filepath) => { .then((filepath) => {
return utils.exec('openssl rsa -in ' + filepath + ' -check -noout') return utils.exec('openssl rsa -in ' + filepath + ' -check -noout')
.then((result) => {
if (!result.toLowerCase().includes('key ok')) {
throw new error.ValidationError(result);
}
fs.unlinkSync(filepath);
return true;
}).catch((err) => {
return utils.exec('openssl ec -in ' + filepath + ' -check -noout')
.then((result) => { .then((result) => {
if (!result.toLowerCase().includes('key ok')) { if (!result.toLowerCase().includes('key ok')) {
throw new error.ValidationError(result); throw new error.ValidationError(result);
@ -621,6 +630,7 @@ const internalCertificate = {
throw new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err); throw new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err);
}); });
}); });
});
}, },
/** /**