When the user specifies they want an embedded config they no longer get a zip file containing everything *and* an embedded config

master
Tim Bazuin 5 years ago
parent e581cda081
commit 21c8c34d7d

@ -16,21 +16,29 @@ class Action extends Session
$zipFile = tempnam(sys_get_temp_dir(), '0zip'); $zipFile = tempnam(sys_get_temp_dir(), '0zip');
$zip = new \ZipArchive(); $zip = new \ZipArchive();
$zip->open($zipFile, \ZipArchive::CREATE); $zip->open($zipFile, \ZipArchive::CREATE);
$cert = $this->post('cert');
$wantEmbedded = $this->post('want-embedded');
$server = ServerQuery::create()->findOneByFingerprint($this->post('fingerprint')); $server = ServerQuery::create()->findOneByFingerprint($this->post('fingerprint'));
$name = $server->getFqdn(); $name = $server->getFqdn();
$this->fillZipWithCaAndConfig($zip, $server); if ($cert !== null && $wantEmbedded !== null) {
$certModel = CertificateQuery::create()->findOneByUserAndName($this->getUser(), $cert);
$cert = $this->post('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); $certModel = CertificateQuery::create()->findOneByUserAndName($this->getUser(), $cert);
$this->addClientCertificateData($zip, $certModel); $this->addClientCertificateData($zip, $certModel);
$this->fillZipWithEmbeddedConfig($zip, $server, $certModel);
$name .= '-' . $certModel->getName() . '.' . $certModel->getSerial(); $name .= '-' . $certModel->getName() . '.' . $certModel->getSerial();
} }
if ($wantEmbedded === null) {
$this->fillZipWithCaAndConfig($zip, $server);
}
$zip->close(); $zip->close();
$zipContents = file_get_contents($zipFile); $zipContents = file_get_contents($zipFile);
@ -68,7 +76,7 @@ class Action extends Session
$parameters = [ $parameters = [
'server' => $server, 'server' => $server,
'crt' => $cert->getCertificate(), 'cert' => $cert->getCertificate(),
'key' => '', 'key' => '',
]; ];

Loading…
Cancel
Save