setasign\SetaPDF2\Signer\X509

Certificate Class representing a X509 Certificate.

File: /SetaPDF v2/Signer/X509/Certificate.php
Old class name (alias): \SetaPDF_Signer_X509_Certificate

Class hierarchy

Summary

Static Properties

$usePhpseclibForRsaPss

Flag defining whether usage of phpseclib or default OpenSSL methods for RSA_PSS validation.

$verifyCallback

A callable that can be used to implement individual verification logic.


Properties

$_certificate

The ASN.1 element holding the X509 certificate.

$_digestCache

protected array Certificate::$_digestCache = array()

A digest cache.

$_extensions

The extensions instance.

$_issuerName

protected array Certificate::$_issuerName = array()

A cache for the issuer name.

$_subjectName

protected array Certificate::$_subjectName = array()

A cache for the subject name.


Static Methods

fromFile()

public static Certificate::fromFile (
string $path
): \SetaPDF_Signer_X509_Certificate

Create an instance by a path.

Parameters
$path : string
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

fromFileOrString()

public static Certificate::fromFileOrString (
string $pathOrString
): \SetaPDF_Signer_X509_Certificate

Create an instance by a path or a string.

Parameters
$pathOrString : string
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception


Methods

__construct()

public Certificate::__construct (
string|\Stringable $certificate
)

The constructor.

Parameters
$certificate : string|\Stringable

PEM or DER encoded string of the certificate.

Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

_getTBSCertificate()

Get the TBSCertificate value.

_getValidity()

Get the validity field.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

get()

public Certificate::get (
string $format = Format::PEM
): string

Get the certificate encoded as DER or PEM.

Parameters
$format : string
 

getAsn1()

Get the ASN.1 instance of the certificate.

getDigest()

public Certificate::getDigest (
string $algo = 'sha1',
bool $raw = false
): string

Get the digest of the certificate.

Parameters
$algo : string
 
$raw : bool
 

getExtensions()

Get the extensions object.

getIssuer()

public Certificate::getIssuer (
Collection $collection
): ?self

Returns the first issuer found in the given Collection.

Parameters
$collection : Collection
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

Throws \setasign\SetaPDF2\Signer\Exception

getIssuerName()

public Certificate::getIssuerName (
bool $asArray = false,
bool $onlyKnown = true
): string|array

Get the issuer name.

Parameters
$asArray : bool

Whether the subject is returned as an array or string

$onlyKnown : bool

Whether attributes with an unknown OID are returend or not.

Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

Throws \setasign\SetaPDF2\Signer\Exception

getIssuerNameRaw()

Get the IssuerName field.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getIssuers()

Get all found issuers found in the given collection.

Parameters
$collection : \SetaPDF_Signer_X509_Collection
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

Throws \setasign\SetaPDF2\Signer\Exception

getSerialNumber()

public Certificate::getSerialNumber (
void
): string

Get the serial number (hex encoded).

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getSerialNumberRaw()

Get the serial number as a raw ASN.1 element.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getSignatureAlgorithm()

public Certificate::getSignatureAlgorithm (
void
): array
Return Values

The first value holds the OID of the algorithm. The second value is the ASN.1 structure of the parameters.

getSignatureValue()

public Certificate::getSignatureValue (
bool $hex = true
): string
Parameters
$hex : bool
 

getSignedData()

getSubjectName()

public Certificate::getSubjectName (
bool $asArray = false,
bool $onlyKnown = true
): string|array

Get the subject name.

Parameters
$asArray : bool

Whether the subject is returned as an array or string

$onlyKnown : bool

Whether attributes with an unknown OID are returend or not.

Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

getSubjectPublicKeyInfoAlgorithmIdentifier()

Get the subject public key info algorithm identifier.

Return Values

First entry is the OID of the identifier. The second entry are the raw parameters as ASN.1 structures.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getSubjectPublicKeyInfoRaw()

public Certificate::getSubjectPublicKeyInfoRaw (
void
): string

Get the data of the Subject Public Key Info field.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getValidFrom()

public Certificate::getValidFrom (
?\DateTimeZone $timeZone = null
): \DateTime

Get the "valid from" value.

Parameters
$timeZone : ?\DateTimeZone

Default timezone is UTC.

Exceptions

Throws \Exception

getValidTo()

public Certificate::getValidTo (
?\DateTimeZone $timeZone = null
): \DateTime

Get the "valid to" value.

Parameters
$timeZone : ?\DateTimeZone

Default timezone is UTC.

Exceptions

Throws \Exception

isValidAt()

public Certificate::isValidAt (
\DateTimeInterface $dateTime,
?\DateTimeZone $timeZone = null
): bool

Checks whether the certificate was valid at a given date and time.

Parameters
$dateTime : \DateTimeInterface
 
$timeZone : ?\DateTimeZone
 
Exceptions

Throws \Exception

verify()

public Certificate::verify (
?\SetaPDF_Signer_X509_Certificate $issuerCertificate = null
): bool

Verify the signed object.

Parameters
$issuerCertificate : ?\SetaPDF_Signer_X509_Certificate

If omitted the certificate instance is used as the issuer (self-signed).

Exceptions

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

Throws \setasign\SetaPDF2\Signer\Exception