Add route to renew certs of a domain

This commit is contained in:
Girish Ramakrishnan
2018-10-24 13:01:45 -07:00
parent 0d04213199
commit ee517da4f4
3 changed files with 33 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ exports = module.exports = {
getCertificate: getCertificate,
renewAll: renewAll,
renewCerts: renewCerts,
configureDefaultServer: configureDefaultServer,
@@ -420,12 +421,11 @@ function unconfigureApp(app, callback) {
});
}
function renewAll(auditSource, callback) {
function renewCerts(options, auditSource, callback) {
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
debug('renewAll: Checking certificates for renewal');
apps.getAll(function (error, allApps) {
if (error) return callback(error);
@@ -444,6 +444,8 @@ function renewAll(auditSource, callback) {
});
});
if (options.domain) appDomains = appDomains.filter(function (appDomain) { return appDomain.domain === options.domain; });
async.eachSeries(appDomains, function (appDomain, iteratorCallback) {
ensureCertificate(appDomain.fqdn, appDomain.domain, auditSource, function (error, bundle) {
if (error) return iteratorCallback(error); // this can happen if cloudron is not setup yet
@@ -471,6 +473,15 @@ function renewAll(auditSource, callback) {
});
}
function renewAll(auditSource, callback) {
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
debug('renewAll: Checking certificates for renewal');
renewCerts({}, auditSource, callback);
}
function removeAppConfigs() {
for (var appConfigFile of fs.readdirSync(paths.NGINX_APPCONFIG_DIR)) {
fs.unlinkSync(path.join(paths.NGINX_APPCONFIG_DIR, appConfigFile));