mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-01-23 05:18:12 -05:00
Merge pull request #666 from MarceloLagos/master
Check key for RSA header otherwise use EC, and output fix.
This commit is contained in:
commit
ffd2430160
@ -608,12 +608,12 @@ const internalCertificate = {
|
|||||||
checkPrivateKey: (private_key) => {
|
checkPrivateKey: (private_key) => {
|
||||||
return tempWrite(private_key, '/tmp')
|
return tempWrite(private_key, '/tmp')
|
||||||
.then((filepath) => {
|
.then((filepath) => {
|
||||||
return utils.exec('openssl rsa -in ' + filepath + ' -check -noout')
|
let key_type = private_key.includes('-----BEGIN RSA') ? 'rsa' : 'ec';
|
||||||
|
return utils.exec('openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ')
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
if (!result.toLowerCase().includes('key ok')) {
|
if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) {
|
||||||
throw new error.ValidationError(result);
|
throw new error.ValidationError('Result Validation Error: ' + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.unlinkSync(filepath);
|
fs.unlinkSync(filepath);
|
||||||
return true;
|
return true;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user