reverseproxy: fix issue where renewed certs are not written to disk
This commit is contained in:
@@ -562,19 +562,6 @@ async function unconfigureApp(app) {
|
||||
await reload();
|
||||
}
|
||||
|
||||
async function ensureCertificates(locations, auditSource, progressCallback) {
|
||||
assert(Array.isArray(locations));
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof progressCallback, 'function');
|
||||
|
||||
let percent = 1;
|
||||
for (const location of locations) {
|
||||
percent += Math.round(100/locations.length);
|
||||
progressCallback({ percent, message: `Ensuring certs of ${location.fqdn}` });
|
||||
await ensureCertificate(location, auditSource);
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupCerts(locations, auditSource, progressCallback) {
|
||||
assert(Array.isArray(locations));
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
@@ -634,7 +621,12 @@ async function checkCerts(options, auditSource, progressCallback) {
|
||||
locations = locations.concat(getAppLocationsSync(app));
|
||||
}
|
||||
|
||||
await ensureCertificates(locations, auditSource, progressCallback);
|
||||
let percent = 1;
|
||||
for (const location of locations) {
|
||||
percent += Math.round(100/locations.length);
|
||||
progressCallback({ percent, message: `Ensuring certs of ${location.fqdn}` });
|
||||
await ensureCertificate(location, auditSource);
|
||||
}
|
||||
|
||||
if (options.rebuild || fs.existsSync(paths.REVERSE_PROXY_REBUILD_FILE)) {
|
||||
progressCallback( { message: 'Rebuilding app configs' });
|
||||
@@ -645,6 +637,12 @@ async function checkCerts(options, auditSource, progressCallback) {
|
||||
await notifyCertChange(); // this allows user to "rebuild" using UI just in case we crashed and went out of sync
|
||||
safe.fs.unlinkSync(paths.REVERSE_PROXY_REBUILD_FILE);
|
||||
} else {
|
||||
// sync all locations and not just the ones that changed. this helps with 0 length certs when disk is full and also
|
||||
// if renewal task crashed midway.
|
||||
for (const location of locations) {
|
||||
await writeCertificate(location);
|
||||
}
|
||||
await reload();
|
||||
await notifyCertChange(); // propagate any cert changes to services
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user