diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 84e3fe13a..52912fb04 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -286,6 +286,13 @@ async function setupTlsAddon(app) { assert.strictEqual(typeof app, 'object'); const certificateDir = `${paths.PLATFORM_DATA_DIR}/tls/${app.id}`; + + // clean up any certs of old locations + const filenames = safe.fs.readdirSync(certificateDir) || []; + for (const filename of filenames) { + safe.fs.unlinkSync(path.join(certificateDir, filename)); + } + for (const location of getAppLocationsSync(app)) { const certificate = await getCertificate(location); writeFileSync(`${certificateDir}/${location.fqdn}.cert`, certificate.cert);