Skip to content

Commit

Permalink
prevent the old cert from being removed if the trust ca command is ca…
Browse files Browse the repository at this point in the history
…nceled
  • Loading branch information
adrum committed Jun 21, 2024
1 parent 72845a3 commit a39a7b0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cli/Valet/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,18 @@ public function secure(string $url, ?string $siteConf = null, int $certificateEx
// Extract in order to later preserve custom PHP version config when securing
$phpVersion = $this->customPhpVersion($url);

$this->unsecure($url);

// Create the CA if it doesn't exist.
// If the user cancels the trust operation, the old certificate will be not removed.
$this->files->ensureDirExists($this->caPath(), user());
$caExpireInDate = (new \DateTime())->diff(new \DateTime("+{$caExpireInYears} years"));
$this->createCa($caExpireInDate->format('%a'));

$this->unsecure($url);

$this->files->ensureDirExists($this->certificatesPath(), user());

$this->files->ensureDirExists($this->nginxPath(), user());

$caExpireInDate = (new \DateTime())->diff(new \DateTime("+{$caExpireInYears} years"));

$this->createCa($caExpireInDate->format('%a'));
$this->createCertificate($url, $certificateExpireInDays);

$siteConf = $this->buildSecureNginxServer($url, $siteConf);
Expand Down

0 comments on commit a39a7b0

Please sign in to comment.