/
home
/
clp
/
htdocs
/
app
/
files
/
src
/
Command
/
up file
home
<?php namespace App\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use App\Command\SiteCommand as SiteCommand; use App\Site\Ssl\DistinguishedName; use App\Site\Ssl\Generator\RsaKeyGenerator; use App\Site\Ssl\Generator\CsrGenerator; use App\Site\Ssl\PrivateKey; use App\Site\Ssl\LetsEncryptClient; use App\Site\Ssl\LetsEncrypt\DomainValidationException; use App\Entity\Certificate as CertificateEntity; use App\Entity\Notification; use App\Notification\NotificationQueue; class LetsEncryptRenewCertificatesCommand extends SiteCommand { const RENEW_DAYS_BEFORE_EXPIRATION = 7; protected function configure() : void { $this->setName("\x6c\x65\164\x73\55\145\156\x63\x72\x79\160\x74\72\162\145\x6e\145\x77\72\x63\x65\162\164\x69\146\151\x63\141\x74\x65\x73"); $this->setDescription("\x63\154\160\143\x74\154\x20\x6c\x65\x74\163\55\x65\x6e\x63\x72\x79\x70\164\72\162\x65\156\145\167\x3a\x63\145\x72\164\151\146\151\143\x61\x74\x65\x73"); } protected function execute(InputInterface $input, OutputInterface $output) : int { try { goto A5d2e; Ee78d: foreach ($siteEntities as $siteEntity) { goto D9165; f1a22: Dabad: goto E72f4; D9165: $certificateEntity = $siteEntity->getCertificate(); goto F2ea2; F2ea2: if (!(CertificateEntity::TYPE_LETS_ENCRYPT == $certificateEntity->getType())) { goto Dabad; } goto b8d69; b8d69: $this->renewCertificate($output, $certificateEntity); goto f1a22; E72f4: E103c: goto D36e7; D36e7: } goto Aa0a4; Ba40a: if (!count($siteEntities)) { goto c1830; } goto Ee78d; A5d2e: $siteEntities = $this->siteEntityManager->findAll(); goto Ba40a; De0d7: return SiteCommand::SUCCESS; goto ecf3c; e3b4e: c1830: goto De0d7; Aa0a4: Fb81b: goto e3b4e; ecf3c: } catch (\Exception $e) { goto f97c5; f97c5: $errorMessage = $e->getMessage(); goto Fabfe; a806a: return SiteCommand::FAILURE; goto b570d; Fabfe: $output->writeln(sprintf("\74\x65\x72\x72\157\x72\76\x25\x73\x3c\x2f\x65\162\x72\157\x72\x3e", $errorMessage)); goto a806a; b570d: } } private function renewCertificate(OutputInterface $output, CertificateEntity $certificateEntity) { goto e3958; fc26c: $daysToExpire = round(($expiresAt->getTimestamp() - $now->getTimestamp()) / 86400, 0); goto A4884; A4884: if (!($daysToExpire <= self::RENEW_DAYS_BEFORE_EXPIRATION)) { goto e0cb2; } goto Da556; f12fb: e0cb2: goto e0f05; Ac7c3: $expiresAt = $certificateEntity->getExpiresAt(); goto fc26c; Da556: try { goto Afd48; c6c9a: if (true === empty($validationErrors)) { goto f10bb; } goto ee979; Aa2ef: $output->writeln(sprintf("\x3c\x69\x6e\x66\157\76\x25\x73\74\x2f\151\x6e\x66\x6f\x3e", $renewingSuccessMessage)); goto e74d2; ebe07: $privateKey = $rsaKeyGenerator->generatePrivateKey(); goto a8b20; aefba: $letsEncryptPrivateKey = $this->getConfigValue("\154\x65\137\x70\162\x69\x76\141\x74\x65\137\x6b\145\171"); goto be9a7; Af6a0: $site = $this->getSite($domainName); goto ad6a5; A184a: $domainName = $siteEntity->getDomainName(); goto Af6a0; a8b20: $csrGenerator = new CsrGenerator($privateKey, $distinguishedName); goto fb927; Fdfdf: $certificateEntity->setCertificate($certificate->getCertificate()); goto Dae46; e6fc4: $this->siteEntityManager->updateEntity($siteEntity); goto D8a59; ad6a5: $domains = $certificateEntity->getDomains(); goto aefba; Dd39a: $siteUpdater->installCertificate($certificateEntity); goto E9f89; Ca31a: $domainValidationException->setValidationErrors($validationErrors); goto Fcc39; Fcc39: throw $domainValidationException; goto Bd55b; b03c5: $distinguishedNameDomains = $domains; goto C914c; be9a7: $privateKey = new PrivateKey($letsEncryptPrivateKey); goto D2d10; C68eb: $letsEncryptClient->registerAccount(); goto e5238; Ae5e1: $validationErrors = $letsEncryptClient->validateDomains($certificateOrder); goto c6c9a; a7b20: f10bb: goto b03c5; dac23: $distinguishedName = new DistinguishedName($commonName, $distinguishedNameDomains); goto f0fd7; ec882: $certificateEntity->setPrivateKey($certificate->getPrivateKey()); goto Fdfdf; Fc52a: $siteUpdater = $this->getSiteUpdater($site); goto A9d18; Dae46: $certificateEntity->setCertificateChain($certificate->getCertificateChain()); goto Dd39a; E9f89: $siteEntity->setCertificate($certificateEntity); goto e6fc4; e74d2: E5d8a: goto E5868; D2d10: $letsEncryptClient = new LetsEncryptClient($privateKey); goto C68eb; eb91a: $certificate = $letsEncryptClient->finalizeOrder($certificateOrder, $privateKey, $csr); goto e21ed; C914c: $commonName = array_shift($distinguishedNameDomains); goto dac23; Afd48: $siteEntity = $certificateEntity->getSite(); goto A184a; Bd55b: goto E5d8a; goto a7b20; A9d18: $siteUpdater->deleteLetsEncryptChallengeDirectory(); goto e0bcc; ee979: $domainValidationException = new DomainValidationException("\x44\x6f\155\x61\x69\x6e\40\166\141\154\151\x64\x61\164\151\x6f\156\40\x66\141\151\154\x65\144"); goto Ca31a; f0fd7: $rsaKeyGenerator = new RsaKeyGenerator(); goto ebe07; e21ed: $certificateEntity->setCsr($certificate->getCsr()); goto ec882; e0bcc: $siteUpdater->createLetsEncryptChallengeFiles($certificateOrder); goto Ae5e1; fb927: $csr = $csrGenerator->generate(); goto eb91a; e5238: $certificateOrder = $letsEncryptClient->requestOrder($domains); goto Fc52a; D8a59: $renewingSuccessMessage = sprintf("\103\x65\x72\x74\151\146\x69\143\x61\164\x65\x20\x72\145\156\x65\167\x69\156\x67\40\146\x6f\162\40\164\x68\145\40\144\x6f\x6d\x61\x69\x6e\x20\42\45\x73\42\x20\x77\141\163\40\163\165\x63\x63\145\163\x73\x66\165\x6c\x2e", $domainName); goto Aa2ef; E5868: } catch (\Exception|DomainValidationException $e) { goto ecbdc; Ecb41: C7f3e: goto e9c1b; bb851: $errorMessage = $e->getMessage(); goto b92ca; Bc483: b972b: goto b8bca; b8bca: $subject = sprintf("\114\x65\x74\x27\x73\40\105\x6e\143\x72\171\x70\164\x20\103\145\162\164\x69\x66\x69\143\x61\x74\x65\x20\162\145\x6e\145\x77\x20\x66\141\x69\154\x65\144\x3a\x20\x25\163\56", $domainName); goto c581f; D20e4: $errorMessage = implode("\54\x20", $validationErrors); goto Bc483; ecbdc: if ($e instanceof DomainValidationException) { goto C7f3e; } goto bb851; b92ca: goto b972b; goto Ecb41; f87ef: c2f7a: goto D20e4; Cafed: foreach ($e->getValidationErrors() as $domainName => $validationError) { $validationErrors[] = sprintf("\x25\163\72\40\x25\163", $domainName, $validationError); b736f: } goto f87ef; e9c1b: $validationErrors = []; goto Cafed; c581f: $this->addNotification($subject, $errorMessage); goto D916e; D916e: } finally { if (!(true === isset($siteUpdater))) { goto bbaed; } $siteUpdater->deleteLetsEncryptChallengeDirectory(); bbaed: } goto f12fb; e3958: $now = new \DateTime("\x6e\x6f\x77"); goto Ac7c3; e0f05: } private function addNotification(string $subject, string $errorMessage) : void { goto A4dae; A4dae: $notification = new Notification(); goto c30ef; c30ef: $notification->setSubject($subject); goto Efd10; aca9c: $notification->setSeverity(Notification::SEVERITY_CRITICAL); goto cce64; cce64: NotificationQueue::addNotification($notification); goto a746d; Efd10: $notification->setMessage($errorMessage); goto aca9c; a746d: } }