mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-03 07:53:39 +00:00
Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
@@ -44,8 +44,7 @@ const internalCertificate = {
|
||||
const cmd = certbotCommand + ' renew --quiet ' +
|
||||
'--config "' + certbotConfig + '" ' +
|
||||
'--preferred-challenges "dns,http" ' +
|
||||
'--no-random-sleep-on-renew ' +
|
||||
'--disable-hook-validation ';
|
||||
'--no-random-sleep-on-renew';
|
||||
|
||||
return utils.exec(cmd)
|
||||
.then((result) => {
|
||||
@@ -637,29 +636,27 @@ const internalCertificate = {
|
||||
checkPrivateKey: (private_key) => {
|
||||
const randomName = crypto.randomBytes(8).toString('hex');
|
||||
const filepath = path.join('/tmp', 'certificate_' + randomName);
|
||||
return fs.writeFileSync(filepath, private_key)
|
||||
.then(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const failTimeout = setTimeout(() => {
|
||||
reject(new error.ValidationError('Result Validation Error: Validation timed out. This could be due to the key being passphrase-protected.'));
|
||||
}, 10000);
|
||||
utils
|
||||
.exec('openssl pkey -in ' + filepath + ' -check -noout 2>&1 ')
|
||||
.then((result) => {
|
||||
clearTimeout(failTimeout);
|
||||
if (!result.toLowerCase().includes('key is valid')) {
|
||||
reject(new error.ValidationError('Result Validation Error: ' + result));
|
||||
}
|
||||
fs.unlinkSync(filepath);
|
||||
resolve(true);
|
||||
})
|
||||
.catch((err) => {
|
||||
clearTimeout(failTimeout);
|
||||
fs.unlinkSync(filepath);
|
||||
reject(new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err));
|
||||
});
|
||||
fs.writeFileSync(filepath, private_key);
|
||||
return new Promise((resolve, reject) => {
|
||||
const failTimeout = setTimeout(() => {
|
||||
reject(new error.ValidationError('Result Validation Error: Validation timed out. This could be due to the key being passphrase-protected.'));
|
||||
}, 10000);
|
||||
utils
|
||||
.exec('openssl pkey -in ' + filepath + ' -check -noout 2>&1 ')
|
||||
.then((result) => {
|
||||
clearTimeout(failTimeout);
|
||||
if (!result.toLowerCase().includes('key is valid')) {
|
||||
reject(new error.ValidationError('Result Validation Error: ' + result));
|
||||
}
|
||||
fs.unlinkSync(filepath);
|
||||
resolve(true);
|
||||
})
|
||||
.catch((err) => {
|
||||
clearTimeout(failTimeout);
|
||||
fs.unlinkSync(filepath);
|
||||
reject(new error.ValidationError('Certificate Key is not valid (' + err.message + ')', err));
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -671,17 +668,15 @@ const internalCertificate = {
|
||||
*/
|
||||
getCertificateInfo: (certificate, throw_expired) => {
|
||||
const randomName = crypto.randomBytes(8).toString('hex');
|
||||
const filepath = path.join('/root', 'certificate_' + randomName);
|
||||
return fs.writeFileSync(filepath, certificate)
|
||||
.then(() => {
|
||||
return internalCertificate.getCertificateInfoFromFile(filepath, throw_expired)
|
||||
.then((certData) => {
|
||||
fs.unlinkSync(filepath);
|
||||
return certData;
|
||||
}).catch((err) => {
|
||||
fs.unlinkSync(filepath);
|
||||
throw err;
|
||||
});
|
||||
const filepath = path.join('/tmp', 'certificate_' + randomName);
|
||||
fs.writeFileSync(filepath, certificate);
|
||||
return internalCertificate.getCertificateInfoFromFile(filepath, throw_expired)
|
||||
.then((certData) => {
|
||||
fs.unlinkSync(filepath);
|
||||
return certData;
|
||||
}).catch((err) => {
|
||||
fs.unlinkSync(filepath);
|
||||
throw err;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -933,8 +928,7 @@ const internalCertificate = {
|
||||
'--config "' + certbotConfig + '" ' +
|
||||
'--cert-name "npm-' + certificate.id + '" ' +
|
||||
'--preferred-challenges "dns,http" ' +
|
||||
'--no-random-sleep-on-renew ' +
|
||||
'--disable-hook-validation ';
|
||||
'--no-random-sleep-on-renew';
|
||||
|
||||
logger.info('Command:', cmd);
|
||||
|
||||
@@ -962,8 +956,7 @@ const internalCertificate = {
|
||||
'--config "' + certbotConfig + '" ' +
|
||||
'--cert-name "npm-' + certificate.id + '" ' +
|
||||
'--preferred-challenges "dns,http" ' +
|
||||
'--no-random-sleep-on-renew ' +
|
||||
'--disable-hook-validation ';
|
||||
'--no-random-sleep-on-renew';
|
||||
|
||||
// Prepend the path to the credentials file as an environment variable
|
||||
if (certificate.meta.dns_provider === 'route53') {
|
||||
@@ -990,6 +983,7 @@ const internalCertificate = {
|
||||
|
||||
const mainCmd = certbotCommand + ' revoke ' +
|
||||
'--config "' + certbotConfig + '" ' +
|
||||
'--cert-path "/data/tls/certbot/live/npm-' + certificate.id + '/privkey.pem" ' +
|
||||
'--cert-path "/data/tls/certbot/live/npm-' + certificate.id + '/fullchain.pem" ' +
|
||||
'--delete-after-revoke';
|
||||
|
||||
|
@@ -4,15 +4,15 @@
|
||||
"description": "A beautiful interface for creating Nginx endpoints",
|
||||
"main": "js/index.js",
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "10.1.0",
|
||||
"@apidevtools/json-schema-ref-parser": "11.1.0",
|
||||
"ajv": "6.12.6",
|
||||
"archiver": "6.0.0",
|
||||
"archiver": "6.0.1",
|
||||
"batchflow": "0.4.0",
|
||||
"bcrypt": "5.1.1",
|
||||
"body-parser": "1.20.2",
|
||||
"compression": "1.7.4",
|
||||
"express": "4.18.2",
|
||||
"express-fileupload": "1.4.0",
|
||||
"express-fileupload": "1.4.1",
|
||||
"gravatar": "1.8.2",
|
||||
"jsonwebtoken": "9.0.2",
|
||||
"knex": "2.5.1",
|
||||
@@ -26,13 +26,10 @@
|
||||
"signale": "1.4.0",
|
||||
"sqlite3": "5.1.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"semver": "7.5.4"
|
||||
},
|
||||
"author": "Jamie Curnow <jc@jc21.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "8.48.0",
|
||||
"eslint": "8.50.0",
|
||||
"eslint-plugin-align-assignments": "1.1.2"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user