Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/Certificate/Extension/SubjectAlternativeNameExtension.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X509\Certificate\Extension;
6
7 use SpomkyLabs\Pki\ASN1\Element;
8 use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
9 use SpomkyLabs\Pki\X509\GeneralName\GeneralNames;
10
11 /**
12 * Implements 'Subject Alternative Name' certificate extension.
13 *
14 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
15 */
16 final class SubjectAlternativeNameExtension extends Extension
17 {
18 private function __construct(
19 bool $critical,
20 private readonly GeneralNames $names
21 ) {
22 parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical);
23 }
24
25 public static function create(bool $critical, GeneralNames $names): self
26 {
27 return new self($critical, $names);
28 }
29
30 public function names(): GeneralNames
31 {
32 return $this->names;
33 }
34
35 protected static function fromDER(string $data, bool $critical): static
36 {
37 return self::create($critical, GeneralNames::fromASN1(UnspecifiedType::fromDER($data)->asSequence()));
38 }
39
40 protected function valueASN1(): Element
41 {
42 return $this->names->toASN1();
43 }
44 }