From 21c8c34d7ddc66a1d2f44e2ce635f712a55e1608 Mon Sep 17 00:00:00 2001 From: Tim Bazuin Date: Sat, 3 Aug 2019 13:45:37 +0200 Subject: [PATCH] When the user specifies they want an embedded config they no longer get a zip file containing everything *and* an embedded config --- src/Handler/Panel/ConfigBuilder/Action.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Handler/Panel/ConfigBuilder/Action.php b/src/Handler/Panel/ConfigBuilder/Action.php index dcd37a3..2636cdf 100644 --- a/src/Handler/Panel/ConfigBuilder/Action.php +++ b/src/Handler/Panel/ConfigBuilder/Action.php @@ -16,21 +16,29 @@ class Action extends Session $zipFile = tempnam(sys_get_temp_dir(), '0zip'); $zip = new \ZipArchive(); $zip->open($zipFile, \ZipArchive::CREATE); + $cert = $this->post('cert'); + $wantEmbedded = $this->post('want-embedded'); + $server = ServerQuery::create()->findOneByFingerprint($this->post('fingerprint')); $name = $server->getFqdn(); - $this->fillZipWithCaAndConfig($zip, $server); - - $cert = $this->post('cert'); + if ($cert !== null && $wantEmbedded !== null) { + $certModel = CertificateQuery::create()->findOneByUserAndName($this->getUser(), $cert); + $this->fillZipWithEmbeddedConfig($zip, $server, $certModel); + $name .= '-' . $certModel->getName() . '.' . $certModel->getSerial(); + } - if ($cert !== null) { + if ($cert !== null && $wantEmbedded === null) { $certModel = CertificateQuery::create()->findOneByUserAndName($this->getUser(), $cert); $this->addClientCertificateData($zip, $certModel); - $this->fillZipWithEmbeddedConfig($zip, $server, $certModel); $name .= '-' . $certModel->getName() . '.' . $certModel->getSerial(); } + if ($wantEmbedded === null) { + $this->fillZipWithCaAndConfig($zip, $server); + } + $zip->close(); $zipContents = file_get_contents($zipFile); @@ -68,7 +76,7 @@ class Action extends Session $parameters = [ 'server' => $server, - 'crt' => $cert->getCertificate(), + 'cert' => $cert->getCertificate(), 'key' => '', ];