CoreFiles by mySites.guru
SubjectKeyIdentifierExtension.php47 lines, 1,194 bytes, from Joomla_5.3.4-Stable-Full_Package.zip
Raw History Compare with 5.3.3
md5
c1b30c12096dc563be219d1f30494b2c
sha1
c473f1edd3af0acf1eb82bcc28532e7ef4851f16
sha256
1546212170ff2ea0ae7190463cae39415e427abd393e4086af97463451f6980f
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X509\Certificate\Extension;

use SpomkyLabs\Pki\ASN1\Element;
use SpomkyLabs\Pki\ASN1\Type\Primitive\OctetString;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;

/**
 * Implements 'Subject Key Identifier' certificate extension.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.2
 */
final class SubjectKeyIdentifierExtension extends Extension
{
    private function __construct(
        bool $critical,
        private readonly string $keyIdentifier
    ) {
        parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical);
    }

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

    /**
     * Get key identifier.
     */
    public function keyIdentifier(): string
    {
        return $this->keyIdentifier;
    }

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

    protected function valueASN1(): Element
    {
        return OctetString::create($this->keyIdentifier);
    }
}

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.