1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

Merge pull request #1498 from adrum/feature/renew-ca

Add the ability to renew the Certificate Authority certificate
This commit is contained in:
Matt Stauffer
2024-12-09 20:37:05 -05:00
committed by GitHub
2 changed files with 28 additions and 8 deletions

View File

@@ -437,9 +437,9 @@ public function secured(): array
/**
* Get all of the URLs with expiration dates that are currently secured.
*/
public function securedWithDates(): array
public function securedWithDates($ca = false): array
{
return collect($this->secured())->map(function ($site) {
$sites = collect($this->secured())->map(function ($site) {
$filePath = $this->certificatesPath().'/'.$site.'.crt';
$expiration = $this->cli->run("openssl x509 -enddate -noout -in $filePath");
@@ -450,7 +450,22 @@ public function securedWithDates(): array
'site' => $site,
'exp' => new DateTime($expiration),
];
})->unique()->values()->all();
})->unique()->values();
if ($ca) {
$filePath = $this->caPath('LaravelValetCASelfSigned.pem');
$expiration = $this->cli->run("openssl x509 -enddate -noout -in $filePath");
$expiration = str_replace('notAfter=', '', $expiration);
$sites->prepend([
'site' => 'Certificate Authority',
'exp' => new DateTime($expiration),
]);
}
return $sites->all();
}
public function isSecured(string $site): bool
@@ -502,8 +517,11 @@ public function secure(string $url, ?string $siteConf = null, int $certificateEx
/**
* Renews all domains with a trusted TLS certificate.
*/
public function renew($expireIn = 368): void
public function renew($expireIn = 368, $ca = false): void
{
if ($ca) {
$this->removeCa();
}
collect($this->securedWithDates())->each(function ($row) use ($expireIn) {
$url = $this->domain($row['site']);