mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 16:10:08 +01:00
restored original secured command
This commit is contained in:
@@ -424,28 +424,38 @@ public function replaceOldLoopbackWithNew(string $siteConf, string $old, string
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the URLs with expiration dates that are currently secured.
|
||||
* Get all of the URLs that are currently secured.
|
||||
*/
|
||||
public function secured(): array
|
||||
{
|
||||
return collect($this->files->scandir($this->certificatesPath()))
|
||||
->filter(function ($file) {
|
||||
return ends_with($file, ['.crt']);
|
||||
return ends_with($file, ['.key', '.csr', '.crt', '.conf']);
|
||||
})->map(function ($file) {
|
||||
|
||||
$host = str_replace(['.crt'], '', $file);
|
||||
|
||||
$filePath = $this->certificatesPath() . '/' . $file;
|
||||
|
||||
$expiration = $this->cli->run("openssl x509 -enddate -noout -in $filePath");
|
||||
|
||||
return [
|
||||
'host' => $host,
|
||||
'exp' => new DateTime(str_replace('notAfter=', '', $expiration)),
|
||||
];
|
||||
return str_replace(['.key', '.csr', '.crt', '.conf'], '', $file);
|
||||
})->unique()->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the URLs with expiration dates that are currently secured.
|
||||
*/
|
||||
public function securedWithDates(): array
|
||||
{
|
||||
return collect($this->secured())->map(function ($site) {
|
||||
|
||||
$filePath = $this->certificatesPath() . '/' . $site . '.crt';
|
||||
|
||||
$expiration = $this->cli->run("openssl x509 -enddate -noout -in $filePath");
|
||||
|
||||
$expiration = str_replace('notAfter=', '', $expiration);
|
||||
|
||||
return [
|
||||
'site' => $site,
|
||||
'exp' => new DateTime($expiration),
|
||||
];
|
||||
})->unique()->values()->all();
|
||||
}
|
||||
|
||||
public function isSecured(string $site): bool
|
||||
{
|
||||
$tld = $this->config->read()['tld'];
|
||||
|
||||
@@ -280,7 +280,7 @@ function (ConsoleCommandEvent $event) {
|
||||
*/
|
||||
$app->command('secured [--expiring] [--days=]', function (OutputInterface $output, $expiring = null, $days = 60) {
|
||||
$now = (new Datetime())->add(new DateInterval('P' . $days . 'D'));
|
||||
$sites = collect(Site::secured())
|
||||
$sites = collect(Site::securedWithDates())
|
||||
->when($expiring, fn ($collection) => $collection->filter(fn ($row) => $row['exp'] < $now))
|
||||
->map(function ($row) {
|
||||
return [
|
||||
@@ -302,7 +302,7 @@ function (ConsoleCommandEvent $event) {
|
||||
$app->command('renew [--expireIn=] [--days=]', function (OutputInterface $output, $expireIn = 368, $days = 60) {
|
||||
$now = (new DateTime())->add(new DateInterval('P' . $days . 'D'));
|
||||
// Update anything expiring in the next 60 days
|
||||
$sites = collect(Site::secured())
|
||||
$sites = collect(Site::securedWithDates())
|
||||
->filter(fn ($row) => $row['exp'] < $now)
|
||||
->values();
|
||||
if ($sites->isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user