CoreFiles by mySites.guru
SubjectAlternativeNameExtension.php44 lines, 1,117 bytes, from Joomla_5.4.3-Stable-Full_Package.zip
Raw History Compare with 5.4.2
md5
7c0fc433e8205502d663953a80078b7f
sha1
a0cc0e1cfc607fa5772720d4a767e7ceb97cd039
sha256
0bb0413fca46c5ac2e09b579662639a174b71e1d35dd60c788008534237b5bc6
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X509\Certificate\Extension;

use SpomkyLabs\Pki\ASN1\Element;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
use SpomkyLabs\Pki\X509\GeneralName\GeneralNames;

/**
 * Implements 'Subject Alternative Name' certificate extension.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
 */
final class SubjectAlternativeNameExtension extends Extension
{
    private function __construct(
        bool $critical,
        private readonly GeneralNames $names
    ) {
        parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical);
    }

    public static function create(bool $critical, GeneralNames $names): self
    {
        return new self($critical, $names);
    }

    public function names(): GeneralNames
    {
        return $this->names;
    }

    protected static function fromDER(string $data, bool $critical): static
    {
        return self::create($critical, GeneralNames::fromASN1(UnspecifiedType::fromDER($data)->asSequence()));
    }

    protected function valueASN1(): Element
    {
        return $this->names->toASN1();
    }
}

The same content is in 158 releases, Joomla 5.0.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.