mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
thrown exception for non LE certificates
This commit is contained in:
parent
1b1807c79a
commit
be87c45f27
@ -337,16 +337,28 @@ const internalCertificate = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {Access} access
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
* @param {Number} data.id
|
* @param {Number} data.id
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
download: (data) => {
|
download: (access, data) => {
|
||||||
const downloadName = 'npm-' + data.id + '-' + `${Date.now()}.zip`;
|
|
||||||
const opName = '/tmp/' + downloadName;
|
|
||||||
const zipDirectory = '/etc/letsencrypt/live/npm-' + data.id;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
access.can('certificates:get', data)
|
||||||
|
.then(() => {
|
||||||
|
return internalCertificate.get(access, data);
|
||||||
|
})
|
||||||
|
.then((certificate) => {
|
||||||
|
if (certificate.provider === 'letsencrypt') {
|
||||||
|
const zipDirectory = '/etc/letsencrypt/live/npm-' + data.id;
|
||||||
|
|
||||||
|
if (!fs.existsSync(zipDirectory)) {
|
||||||
|
throw new error.ItemNotFoundError('Certificate ' + certificate.nice_name + ' does not exists');
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadName = 'npm-' + data.id + '-' + `${Date.now()}.zip`;
|
||||||
|
const opName = '/tmp/' + downloadName;
|
||||||
internalCertificate.zipDirectory(zipDirectory, opName)
|
internalCertificate.zipDirectory(zipDirectory, opName)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
logger.debug('zip completed : ', opName);
|
logger.debug('zip completed : ', opName);
|
||||||
@ -357,6 +369,10 @@ const internalCertificate = {
|
|||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw new error.ValidationError('Only Let\'sEncrypt certificates can be renewed');
|
||||||
|
}
|
||||||
|
}).catch((err) => reject(err));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ router
|
|||||||
* Renew certificate
|
* Renew certificate
|
||||||
*/
|
*/
|
||||||
.get((req, res, next) => {
|
.get((req, res, next) => {
|
||||||
internalCertificate.download({
|
internalCertificate.download(res.locals.access, {
|
||||||
id: parseInt(req.params.certificate_id, 10)
|
id: parseInt(req.params.certificate_id, 10)
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user