Skip to content

Commit 84ff43c

Browse files
Version 1.1.2
Add site check Rename commands Resolve #2 #1
1 parent 951fbc2 commit 84ff43c

File tree

8 files changed

+3301
-1876
lines changed

8 files changed

+3301
-1876
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ certinfo
2929
### Check a single file
3030

3131
```
32-
certinfo certificate:check <filename>
32+
certinfo check:file <filename>
3333
```
3434

3535
_filename_ can be a PEM, CRT, CER or DER file
@@ -39,11 +39,17 @@ _filename_ can be a PEM, CRT, CER or DER file
3939
### Check every file in a directory
4040

4141
```
42-
certinfo certificate:check-dir <directory>
42+
certinfo check:directory <directory>
4343
```
4444

4545
![](readme_img_dir.png)
4646

47+
### Check an HTTPS Url
48+
49+
```
50+
certinfo check:url <url>
51+
```
52+
4753
### Convert PEM to DER
4854

4955
```

app/Commands/CheckDirCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class CheckDirCommand extends Command
1313
{
14-
protected $signature = 'certificate:check-dir
14+
protected $signature = 'check:directory
1515
{directory : the directory to scan (required)}
1616
';
1717

app/Commands/CheckSingleFileCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class CheckSingleFileCommand extends Command
1313
{
14-
protected $signature = 'certificate:check
14+
protected $signature = 'check:file
1515
{file : the certificate file (required)}
1616
';
1717

app/Commands/CheckUrlCommand.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace App\Commands;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use LaravelZero\Framework\Commands\Command;
7+
use Spatie\SslCertificate\SslCertificate;
8+
9+
class CheckUrlCommand extends Command
10+
{
11+
protected $signature = 'check:url
12+
{url : site to check (required)}
13+
';
14+
15+
protected $description = 'Get validity of the certificate of a site';
16+
17+
public function handle(): mixed
18+
{
19+
$this->info("");
20+
$url = $this->argument('url');
21+
22+
try {
23+
$certificate = SslCertificate::createForHostName($url);
24+
$this->table(['URL', $url],[
25+
['Domain/CN', $certificate->getDomain()],
26+
['Issuer', $certificate->getIssuer()],
27+
['Organization', $certificate->getOrganization()],
28+
['Serial number', $certificate->getSerialNumber()],
29+
['Valid for', $certificate->daysUntilExpirationDate()." days"],
30+
['Valid until', $certificate->expirationDate()->format('d-m-Y')],
31+
]);
32+
} catch (\Exception $e) {
33+
$this->warn($url.": is not a valid SSL Site");
34+
return 1;
35+
}
36+
37+
return 0;
38+
}
39+
40+
public function schedule(Schedule $schedule): void
41+
{
42+
// $schedule->command(static::class)->everyMinute();
43+
}
44+
}

builds/certinfo

583 KB
Binary file not shown.

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
],
1818
"require": {
1919
"php": "^8.1",
20+
"guzzlehttp/guzzle": "^7.4",
21+
"illuminate/http": "^9.0",
2022
"nunomaduro/termwind": "^1.13",
2123
"spatie/ray": "^1.36",
2224
"spatie/ssl-certificate": "^2.4"

0 commit comments

Comments
 (0)