Skip to content

Enums, contracts and exceptions

A lookup page. Everything here is named somewhere else in the guide, in the place where it matters; this is where to come when you know the name and want the shape.

Enums

A closed set of values is an enum here rather than a string validated on every call, and every entry point that takes one also takes its backing value, so configuration can stay as plain strings and never has to import anything.

php
->profile(SignatureProfile::PadesBT)
->profile('pades-b-t')          // the same thing

The ones you pass in

EnumCasesUsed by
SignatureProfilelegacy, pades-b-b, pades-b-t, pades-b-lt, pades-b-ltaProfiles
DigestAlgorithmsha256, sha384, sha512Configuration
CertificationLevelno-changes, form-filling, annotationsCertification
FieldLockActionall, include, excludeCertification, behind Data\FieldLock
SealPagefirst, lastSeals
FontSizesmall, medium, largeSeals
ImageDrivergd, imagickSeals

The ones you read back

EnumCasesReported by
ValidationFindingsixteen, listed in Verifying signatures$report->findings()
RevocationStatusgood, revoked, unknown$signature->revocation
RevisionChangesignature-added, timestamp-added, security-store-written, annotations, form-fields, pages, catalog, actions, other$signature->changesAfter
SigningEventsignature.applied, timestamp.received, validation.completed, validation.failedAudit trail
ExtendExitCodethe status signet extend exits withCommand line

The ones that describe a format

Asn1Tag, CmsAttribute, Cipher, DigestOid, EncryptionAlgorithm, SealEncoding and StreamFilter name what a specification defines rather than a choice a caller makes. They are public because the classes returning them are, and there is rarely a reason to reach for one.

Contracts

Eleven interfaces, and nothing binds them: Signet wires the default graph by hand and its constructor is where a replacement goes.

ContractReplacing it buys
SignatureTransportthe TSA, OCSP and CRL calls, which is your SSRF surface
ProcessRunnerthe only seam that starts a process
PdfSignerthe signer itself, which is how Testing\FakePdfSigner is installed
CertificateReaderhow a certificate is parsed
SealRenderera seal of your own: a logo, a QR code, any layout
Encrypterthe key management and cipher the vault seals with
PdfSourcedocuments that are not local files
PdfDestinationsomewhere to write that is not a path
SignatureValidatorthe validator behind Signet::validate()
SignatureProducerwho makes the CMS, which is how a key on a token, in an HSM or behind a cloud service is used (two-phase signing)
SignatureVerifierwhich implementation decides that a signature matches its bytes: the openssl binary by default, or Validation\NativeSignatureVerifier, which needs no process
php
$signet = new Signet(
    config: $config,
    processes: $processRunner,
    transport: $transport,
    signer: $signer,
    certificateReader: $reader,
    verifier: $verifier,
);

SealRenderer and Encrypter are constructor arguments of the classes holding them rather than of Signet. The last three are implemented rather than replaced.

Exceptions

Twenty classes, one per failure mode, and every one implements Exceptions\SignetException, which extends Throwable. Catch the interface to handle the package's failures as a group.

Raised byClass
CertificatesInvalidCertificatePasswordException, InvalidCertificateContentException, InvalidPFXException, InvalidPemContentException, InvalidX509PrivateKeyException, CertificateOutputNotFoundException
DocumentsInvalidPdfFileException, FileNotFoundException, HasNoSignatureOrInvalidPkcs7Exception
SigningSealPlacementException, SignatureFieldException, CertificationException, FieldLockException
VerifyingVerificationUnsupportedException, raised by the native verifier for a signature algorithm it cannot express rather than reporting the signature bad
The environmentMissingBinaryException, ProcessUnavailableException, ProcessRunTimeException
Network and storageSignatureTransportException, EncryptionException
The interface itselfSignetException

InvalidCertificatePasswordException extends InvalidCertificateContentException, the class it used to arrive as, so code catching the general failure still works while code that wants to say "wrong password, ask again" can.

What each one means in practice, and what to do about it, is Troubleshooting.

Documents in and out

Class
Io\FileSourcea path
Io\StringSourcebytes in memory
Io\StreamSourcean open handle
Io\FileDestinationa directory or path to write to
Io\StreamDestinationan open handle to write to

What comes back

ClassReturned by
Data\SignedPdfsign(), and complete()
Data\PreparedSignatureprepare(), carrying the document, the byte range and the digest to be signed
Data\SignatureReportvalidate()
Data\SignatureDetails$report->latest(), and each entry of the report
Data\Signer$report->signers(), and each link of a chain
Data\SignatureFieldsignatureFields()
Data\EncryptedCertificateencryptCertificate(), carrying certificate, password and hash
Data\Certificatethe certificate readers
Data\RevisionDiff$signature->changesAfter
Data\SecurityStore$report->securityStore
Data\SignaturePolicy$signature->signaturePolicy, when the signer declared one
IcpBrasil\Data\Identity$signer->icpBrasil
IcpBrasil\Data\ReporticpBrasil()

All of them are final readonly, so what you receive is what was measured.

Released under the MIT Licence.