From 453b30c55cda49539ed9b3a8a8924d810b0cc9a6 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 31 Oct 2024 22:43:25 +0700 Subject: [PATCH] fix(dashmate): zero ssl certificate draft not saved (#2297) --- .../ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js | 7 +++++++ .../src/ssl/zerossl/validateZeroSslCertificateFactory.js | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js b/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js index ca679233d03..76aed5e6fc3 100644 --- a/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js @@ -18,6 +18,8 @@ import { ERRORS } from '../../../../ssl/zerossl/validateZeroSslCertificateFactor * @param {VerificationServer} verificationServer * @param {HomeDir} homeDir * @param {validateZeroSslCertificate} validateZeroSslCertificate + * @param {ConfigFileJsonRepository} configFileRepository + * @param {ConfigFile} configFile * @return {obtainZeroSSLCertificateTask} */ export default function obtainZeroSSLCertificateTaskFactory( @@ -32,6 +34,8 @@ export default function obtainZeroSSLCertificateTaskFactory( verificationServer, homeDir, validateZeroSslCertificate, + configFileRepository, + configFile, ) { /** * @typedef {obtainZeroSSLCertificateTask} @@ -141,6 +145,9 @@ export default function obtainZeroSSLCertificateTaskFactory( config.set('platform.gateway.ssl.enabled', true); config.set('platform.gateway.ssl.provider', 'zerossl'); config.set('platform.gateway.ssl.providerConfigs.zerossl.id', ctx.certificate.id); + + // Save config file + configFileRepository.write(configFile); }, }, { diff --git a/packages/dashmate/src/ssl/zerossl/validateZeroSslCertificateFactory.js b/packages/dashmate/src/ssl/zerossl/validateZeroSslCertificateFactory.js index 20b221216c5..53f3da5b56e 100644 --- a/packages/dashmate/src/ssl/zerossl/validateZeroSslCertificateFactory.js +++ b/packages/dashmate/src/ssl/zerossl/validateZeroSslCertificateFactory.js @@ -104,10 +104,7 @@ export default function validateZeroSslCertificateFactory(homeDir, getCertificat } if (['pending_validation', 'draft'].includes(data.certificate.status)) { - // Certificate is already created, so we just need to pass validation - // and download certificate file - - // We need to download new certificate bundle + // We need to validate and download new certificate bundle data.isBundleFilePresent = false; return { @@ -116,6 +113,9 @@ export default function validateZeroSslCertificateFactory(homeDir, getCertificat }; } + // Certificate is already created at this point, so we just need to pass validation + // and download certificate file + if (data.certificate.status !== 'issued' || data.isExpiresSoon) { // Certificate is going to expire soon, or current certificate is not valid // we need to obtain a new one