Skip to content

Commit

Permalink
Version 1.1.2
Browse files Browse the repository at this point in the history
Add site check
Rename commands

Resolve #2 #1
  • Loading branch information
marco-introini committed Dec 3, 2022
1 parent 951fbc2 commit 84ff43c
Show file tree
Hide file tree
Showing 8 changed files with 3,301 additions and 1,876 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ certinfo
### Check a single file

```
certinfo certificate:check <filename>
certinfo check:file <filename>
```

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

```
certinfo certificate:check-dir <directory>
certinfo check:directory <directory>
```

![](readme_img_dir.png)

### Check an HTTPS Url

```
certinfo check:url <url>
```

### Convert PEM to DER

```
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/CheckDirCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class CheckDirCommand extends Command
{
protected $signature = 'certificate:check-dir
protected $signature = 'check:directory
{directory : the directory to scan (required)}
';

Expand Down
2 changes: 1 addition & 1 deletion app/Commands/CheckSingleFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class CheckSingleFileCommand extends Command
{
protected $signature = 'certificate:check
protected $signature = 'check:file
{file : the certificate file (required)}
';

Expand Down
44 changes: 44 additions & 0 deletions app/Commands/CheckUrlCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Spatie\SslCertificate\SslCertificate;

class CheckUrlCommand extends Command
{
protected $signature = 'check:url
{url : site to check (required)}
';

protected $description = 'Get validity of the certificate of a site';

public function handle(): mixed
{
$this->info("");
$url = $this->argument('url');

try {
$certificate = SslCertificate::createForHostName($url);
$this->table(['URL', $url],[
['Domain/CN', $certificate->getDomain()],
['Issuer', $certificate->getIssuer()],
['Organization', $certificate->getOrganization()],
['Serial number', $certificate->getSerialNumber()],
['Valid for', $certificate->daysUntilExpirationDate()." days"],
['Valid until', $certificate->expirationDate()->format('d-m-Y')],
]);
} catch (\Exception $e) {
$this->warn($url.": is not a valid SSL Site");
return 1;
}

return 0;
}

public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}
Binary file modified builds/certinfo
Binary file not shown.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
],
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.4",
"illuminate/http": "^9.0",
"nunomaduro/termwind": "^1.13",
"spatie/ray": "^1.36",
"spatie/ssl-certificate": "^2.4"
Expand Down
Loading

0 comments on commit 84ff43c

Please sign in to comment.