Skip to content

Configuration

There is no configuration file to read, and no environment to consult. Config\SignetConfig and the five objects under it carry resolved values, and an application that has a configuration file translates it at its own edge.

That is deliberate: a library that reads configuration decides where configuration lives, and this one has no business deciding that (0100).

php
use LSNepomuceno\Signet\Signet;
use LSNepomuceno\Signet\Config\SignetConfig;

$signet = new Signet(new SignetConfig(
    signing: new SigningConfig(...),
    certificate: new CertificateConfig(...),
    seal: new SealConfig(...),
    tempPath: '/var/tmp/signet',
));

Every argument is defaulted, so new Signet() is a complete, working object.

SignetConfig

PropertyDefaultMeaning
signingnew SigningConfig()profile, digest, timestamp, LTV
certificatenew CertificateConfig()which reader, and how it finds openssl
sealnew SealConfig()how a seal is drawn
tempPathnullthe scratch directory. null means the system temporary directory

tempPath must be absolute

A relative path resolves against the working directory, which for a queue worker or a web request is wherever the process happened to start. Both path() and file() refuse one with ProcessRunTimeException, because a temporary file here holds a PEM private key on its way to openssl and there is no correct directory to guess.

SigningConfig

PropertyDefaultMeaning
profileSignatureProfile::PadesBBthe level every signature takes unless the builder says otherwise
digestDigestAlgorithm::Sha256Sha256, Sha384 or Sha512
timestampnew TimestampConfig()the authority
ltvnew LtvConfig()the budget for fetching revocation material

TimestampConfig

PropertyDefaultMeaning
urlnullthe authority. Required from pades-b-t up
username, passwordnullHTTP authentication, when the authority wants it
timeout20seconds
attempts3a TSA is somebody else's HTTP service
backoff200milliseconds between attempts

LtvConfig

PropertyDefaultMeaning
timeout10seconds
attempts2
backoff100milliseconds

Separate from the timestamp budget on purpose: fetching an OCSP response and reaching a timestamp authority fail differently and deserve different patience.

CertificateConfig

PropertyDefaultMeaning
legacyfalseuse the CLI reader, for a PFX OpenSSL 3.x refuses natively
usePathEnvfalselet the process inherit PATH when locating openssl

SealConfig

PropertyDefaultMeaning
driverImageDriver::Gdor ImageDriver::Imagick
fontPathnulla TrueType font for the seal text
fontSizeFontSize::LargeSmall, Medium, Large
fontColor'#16A085'
backgroundnullan image drawn behind the text
transparenttrue
textX160where the text starts
textRows[80, 150, 250]the vertical position of each line

Substituting the parts

Signet's constructor is also the substitution point. Four collaborators can be replaced without a container:

php
$signet = new Signet(
    config: $config,
    processes: $processRunner,           // Contracts\ProcessRunner
    transport: $transport,               // Contracts\SignatureTransport
    signer: $signer,                     // Contracts\PdfSigner
    certificateReader: $reader,          // Contracts\CertificateReader
);

That is how the test doubles are installed (Testing), and how an application owns the network surface (Profiles).

Using your own container instead

Signet is a convenience over the parts, never a layer in front of them. Nothing in src/ depends on it and every class it builds can be built directly, so an application with a container should register those classes and ignore the entry point entirely.

Released under the MIT Licence.