mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 08:10:07 +01:00
add the ability to see the Certificate Authority expiration date
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -285,9 +285,9 @@ function (ConsoleCommandEvent $event) {
|
||||
/**
|
||||
* Display all of the currently secured sites.
|
||||
*/
|
||||
$app->command('secured [--expiring] [--days=]', function (OutputInterface $output, $expiring = null, $days = 60) {
|
||||
$app->command('secured [--expiring] [--days=] [--ca]', function (OutputInterface $output, $expiring = null, $days = 60, $ca = null) {
|
||||
$now = (new Datetime)->add(new DateInterval('P'.$days.'D'));
|
||||
$sites = collect(Site::securedWithDates())
|
||||
$sites = collect(Site::securedWithDates($ca))
|
||||
->when($expiring, fn ($collection) => $collection->filter(fn ($row) => $row['exp'] < $now))
|
||||
->map(function ($row) {
|
||||
return [
|
||||
@@ -301,6 +301,7 @@ function (ConsoleCommandEvent $event) {
|
||||
})->descriptions('Display all of the currently secured sites', [
|
||||
'--expiring' => 'Limits the results to only sites expiring within the next 60 days.',
|
||||
'--days' => 'To be used with --expiring. Limits the results to only sites expiring within the next X days. Default is set to 60.',
|
||||
'--ca' => 'Include the Certificate Authority certificate in the list of site certificates.',
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user