diff --git a/app/Classes/LDAP/Attribute/Certificate.php b/app/Classes/LDAP/Attribute/Certificate.php index 95908db8..53542c1c 100644 --- a/app/Classes/LDAP/Attribute/Certificate.php +++ b/app/Classes/LDAP/Attribute/Certificate.php @@ -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); + } } \ No newline at end of file diff --git a/resources/lang/zz.json b/resources/lang/zz.json index c5d6ae1a..b6e6ea47 100644 --- a/resources/lang/zz.json +++ b/resources/lang/zz.json @@ -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", diff --git a/resources/views/components/syntax/certificate.blade.php b/resources/views/components/syntax/certificate.blade.php index 48f9fe4d..60f6bc33 100644 --- a/resources/views/components/syntax/certificate.blade.php +++ b/resources/views/components/syntax/certificate.blade.php @@ -16,9 +16,29 @@ @endif -
- @lang('Certificate Subject'): {{ $o->subject($loop->index) }}
- {{ ($expire=$o->expires($loop->index))->isPast() ? __('Expired') : __('Expires') }}: {{ $expire->format(config('pla.datetime_format','Y-m-d H:i:s')) }} +
+ + + + + + + + + + + + + + + + + + + + + +
@lang('Certificate Subject'){{ $o->subject($loop->index) }}
{{ ($expire=$o->expires($loop->index))->isPast() ? __('Expired') : __('Expires') }}{{ $expire->format(config('pla.datetime_format','Y-m-d H:i:s')) }}
@lang('Serial Number'){{ $o->cert_info('serialNumberHex',$loop->index) }}
@lang('Subject Key Identifier'){{ $o->subject_key_identifier($loop->index) }}
@lang('Authority Key Identifier'){{ $o->authority_key_identifier($loop->index) }}
@else