1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

added the ability to renew certs and view their expiration dates

This commit is contained in:
Austin Drummond
2023-12-19 23:23:02 -05:00
parent c4fb099eea
commit eec8d5f0fc
2 changed files with 57 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
namespace Valet;
use DateTime;
use DomainException;
use Illuminate\Support\Collection;
use PhpFpm;
@@ -423,15 +424,25 @@ public function replaceOldLoopbackWithNew(string $siteConf, string $old, string
}
/**
* Get all of the URLs that are currently secured.
* Get all of the URLs with expiration dates that are currently secured.
*/
public function secured(): array
{
return collect($this->files->scandir($this->certificatesPath()))
->filter(function ($file) {
return ends_with($file, ['.key', '.csr', '.crt', '.conf']);
return ends_with($file, ['.crt']);
})->map(function ($file) {
return str_replace(['.key', '.csr', '.crt', '.conf'], '', $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)),
];
})->unique()->values()->all();
}