Add more Certificate Serial Number, Subject and Authority Key IDs
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 28s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 2m55s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2025-06-03 22:49:04 +10:00
parent 7854cbdabd
commit 06b7c204b0
3 changed files with 43 additions and 6 deletions

View File

@ -4,6 +4,7 @@ namespace App\Classes\LDAP\Attribute;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use App\Classes\LDAP\Attribute;
use App\Traits\MD5Updates;
@ -17,6 +18,15 @@ final class Certificate extends Attribute
private array $_object = [];
public function authority_key_identifier(int $key=0): string
{
$data = collect(explode("\n",$this->cert_info('extensions.authorityKeyIdentifier',$key)));
return $data
->filter(fn($item)=>Str::startsWith($item,'keyid:'))
->map(fn($item)=>Str::after($item,'keyid:'))
->first();
}
public function certificate(int $key=0): string
{
return sprintf("-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----",
@ -29,19 +39,23 @@ final class Certificate extends Attribute
if (! array_key_exists($key,$this->_object))
$this->_object[$key] = openssl_x509_parse(openssl_x509_read($this->certificate($key)));
return Arr::get($this->_object[$key],$index);
}
public function expires($key=0): Carbon
public function expires(int $key=0): Carbon
{
return Carbon::createFromTimestampUTC($this->cert_info('validTo_time_t',$key));
}
public function subject($key=0): string
public function subject(int $key=0): string
{
$subject = collect($this->cert_info('subject',$key))->reverse();
return $subject->map(fn($item,$key)=>sprintf("%s=%s",$key,$item))->join(',');
}
public function subject_key_identifier(int $key=0): string
{
return $this->cert_info('extensions.subjectKeyIdentifier',$key);
}
}

View File

@ -11,6 +11,7 @@
"Attributes": "ZAttributes",
"attributes(s)": "Zattributes(s)",
"Attribute Types": "ZAttribute Types",
"Authority Key Identifier": "ZAuthority Key Identifier",
"Certificate Subject": "ZCertificate Subject",
"Check": "ZCheck",
"Check Password": "ZCheck Password",
@ -108,11 +109,13 @@
"Select a Structural ObjectClass...": "ZSelect a Structural ObjectClass...",
"Select attribute...": "ZSelect attribute...",
"Select from": "ZSelect from",
"Serial Number": "ZSerial Number",
"Server": "ZServer",
"Server Info": "ZServer Info",
"Single Valued": "ZSingle Valued",
"Step": "ZStep",
"structural": "Zstructural",
"Subject Key Identifier": "ZSubject Key Identifier",
"Substring Rule": "ZSubstring Rule",
"Syntax": "ZSyntax",
"Syntaxes": "ZSyntaxes",

View File

@ -16,9 +16,29 @@
@endif
</div>
</div>
<div class="input-helper">
@lang('Certificate Subject'): <strong>{{ $o->subject($loop->index) }}</strong><br/>
{{ ($expire=$o->expires($loop->index))->isPast() ? __('Expired') : __('Expires') }}: <strong>{{ $expire->format(config('pla.datetime_format','Y-m-d H:i:s')) }}</strong>
<div class="input-helper small">
<table class="table table-borderless w-75">
<tr >
<td class="p-0">@lang('Certificate Subject')</td>
<th class="p-0">{{ $o->subject($loop->index) }}</th>
</tr>
<tr>
<td class="p-0">{{ ($expire=$o->expires($loop->index))->isPast() ? __('Expired') : __('Expires') }}</td>
<th class="p-0">{{ $expire->format(config('pla.datetime_format','Y-m-d H:i:s')) }}</th>
</tr>
<tr>
<td class="p-0">@lang('Serial Number')</td>
<th class="p-0">{{ $o->cert_info('serialNumberHex',$loop->index) }}</th>
</tr>
<tr>
<td class="p-0">@lang('Subject Key Identifier')</td>
<th class="p-0">{{ $o->subject_key_identifier($loop->index) }}</th>
</tr>
<tr>
<td class="p-0">@lang('Authority Key Identifier')</td>
<th class="p-0">{{ $o->authority_key_identifier($loop->index) }}</th>
</tr>
</table>
</div>
@else