Download the PHP package jeidison/signer-php without Composer
On this page you can find all versions of the php package jeidison/signer-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeidison/signer-php
More information about jeidison/signer-php
Files in jeidison/signer-php
Package signer-php
Short Description Open-source PHP library for PDF digital signing with multiple signatures, RFC3161 timestamping, PAdES profiles, and PDF protection
License MIT
Informations about the package signer-php
Signer PHP (PDF Module)
PHP library to digitally sign PDFs using A1 certificates (.pfx/.p12) with a simple, developer-friendly API.
What problem it solves
If you need backend PDF signing with cryptographic validity, this library provides a direct flow to:
- apply digital signatures to PDF files
- include signer metadata
- add visible signatures (image)
- apply RFC3161 timestamping (TSA)
- sign the same PDF multiple times (incremental flow)
Main features
- PKCS#12 (
.pfx/.p12) digital signature - Fluent builder API (
Signer::signer()) - Invisible signature
- Visible signature with background image (
PNG/JPEG), contain-scaled and centred - Visible signature with drawn signature image on a configurable sub-area of the bbox
- Visible signature with custom PDF content stream (text, graphics) in the n2 layer
- Automatic default visible appearance (built-in fallback)
- Signature metadata (
name,contactInfo,reason,location) - DocMDP certification (levels 1, 2 and 3)
- Brazil policy mode (
br-iti) signing preset - PAdES Baseline-B profile mode (SubFilter
ETSI.CAdES.detached) - PAdES Baseline-T profile mode (PAdES-B + required timestamp)
- PAdES Baseline-LT profile mode (PAdES-T + embedded DSS/Certs)
- PAdES Baseline-LTA profile mode (PAdES-LT + extra archival timestamp)
- Multiple signatures in the same document
- Optional RFC3161 timestamping
- RFC3161 timestamping with public default TSA when enabled (
withTimestamp()) - PDF permission protection (for example, block content copying)
- Validation of existing digital signatures in PDF files
Requirements
- PHP
^8.2 ext-opensslext-curl- recommended:
ext-zlibandext-fileinfo
Installation
Install with Composer:
Usage
1) Basic signature
By default, the library applies a fallback visible appearance with a styled built-in stamp (internal image + default position) for simpler usage.
If you already have PKCS#12 in memory, use content instead of a file path:
2) Signature with metadata
3) Visible signature with background image
The image is placed in the n0 layer and scaled with contain logic (aspect ratio preserved, centred inside the bbox).
A base64-encoded string is also accepted:
3.1) Visible signature with signer's drawn image
To show the signer's drawn PNG on a specific area of the bbox (e.g. left half), use signatureImagePath and signatureImageFrame. This places the image as an external XObject in the n2 layer, independently from the n0 background.
3.2) Visible signature with custom content stream (n2 layer)
To embed arbitrary PDF text or graphics operators in the n2 layer — for example, the signer's name, date and reason — pass a SignatureAppearanceXObjectDto with the stream and its resource dictionary.
4) Disable default appearance (invisible signature)
5) Multiple signatures in the same PDF
Use the signed output as input for the next signature:
6) Signature with RFC3161 timestamp
To enable timestamping with default configuration, call withTimestamp().
In this case, the library uses a public default TSA (https://freetsa.org/tsr).
If you want a custom TSA only for this signing flow, use withTimestamp(new TimestampOptionsDto(...)).
The hashAlgorithm field accepts HashAlgorithm (recommended) or a compatible string (sha256, sha384, sha512, sha224, sha1).
6.1) Override the default TSA for this flow
6.2) Disable default timestamping
6.3) Real TSA test and token generation (RFC3161)
For SaaS/API flows, you can run a real TSA routine (not only endpoint ping) using the timestamp facade:
6.3) Enable PAdES Baseline-B profile
6.4) Enable PAdES Baseline-T profile
In PAdES-T mode, timestamp must be active (for example, withTimestamp(...)).
6.5) Enable PAdES Baseline-LT profile
In PAdES-LT mode, besides timestamping, the library applies DSS enrichment with certificates extracted from CMS/RFC3161 signatures.
6.6) Enable PAdES Baseline-LTA profile
In PAdES-LTA mode, after LT enrichment, the library adds one extra archival Document Timestamp on the final document revision.
6.7) Define document certification (DocMDP)
Available levels:
CertificationLevel::NoChangesAllowed(1): no changes allowed after certification.CertificationLevel::FormFillAndSignatures(2): allows form filling and additional signatures.CertificationLevel::FormFillSignaturesAndAnnotations(3): allows forms, signatures, and annotations.
Default behavior:
- Without
withCertificationLevel(...), DocMDP is not explicitly set (null). - In
withBrazilPolicy(...), the library forcesCertificationLevel::FormFillAndSignatures(level2).
6.8) Brazil policy mode (br-iti)
This preset applies PAdES-LTA + DocMDP=2 + explicit policy timestamp.
To switch quickly to another TSA:
SERPRO support (homologation):
- OAuth2 token:
https://gateway.apiserpro.serpro.gov.br/token - ASN.1 timestamp endpoint:
https://gateway.apiserpro.serpro.gov.br/apitimestamp/v1/stamps-asn1
SERPRO helper example:
7) Protect PDF (block copy/print/modify)
8) Recommended flow: protect and sign in the same builder
Use this flow to avoid ordering mistakes and ensure the signature is applied on the already protected PDF.
9) Validate digital signatures in a PDF
9.1) Validation with trust chain (trust store)
9.2) Validation with Brazil policy mode (br-iti)
withBrazilPolicy(...) trust store precedence:
- If
trustStorePathis provided, it is used directly. - If
trustStorePathisnull, the library automatically builds/updates a local cached ICP-Brasil bundle and uses it.
If trustStorePath is null, br-iti mode builds an ICP-Brasil trust anchors bundle automatically in local cache:
- default directory:
sys_get_temp_dir()/signer-php/trust-anchors - default URLs:
http://acraiz.icpbrasil.gov.br/Certificado_AC_Raiz.crthttp://acraiz.icpbrasil.gov.br/credenciadas/RAIZ/ICP-Brasilv2.crthttp://acraiz.icpbrasil.gov.br/credenciadas/RAIZ/ICP-Brasilv5.crthttp://acraiz.icpbrasil.gov.br/credenciadas/RAIZ/ICP-Brasilv6.crthttp://acraiz.icpbrasil.gov.br/credenciadas/RAIZ/ICP-Brasilv7.crt
In br-iti mode, validation also verifies ICP-Brasil PAdES policy list (LPA):
https://politicas.icpbrasil.gov.br/LPA_PAdES.derhttps://politicas.icpbrasil.gov.br/LPA_PAdES.p7s
You can override these URLs:
9.3) How to interpret trustValid and policyValid
trustValid = true: certificate chain is valid for the trust store in use.trustValid = false: chain is invalid, incomplete, or not trusted by the trust store in use.trustValid = null: trust chain validation was not executed for that signature.policyValid = true: PAdES LPA check (ICP-Brasil or overridden URLs) passed.policyValid = false: policy/LPA check failed for that signature.policyValid = null: policy mode was not requested in the flow.
Signature inspection via CLI
Besides signing, the project provides bin/signer-inspect for technical diagnostics of signed PDFs.
Basic usage
JSON output
Main inspection fields:
inferred_profile: inferred profile (pades-baseline-b,t,lt,lta).features: presence ofDSS,VRI,DocMDP,OCSPs,CRLs.revocation_endpoints: OCSP/CRL endpoints per discovered certificate.revocation_risk_summary: connectivity/missing-endpoint risk flags.
This inspection helps explain warnings reported by external validators (for example CRL/OCSP connectivity issues).
Environment diagnostics via CLI
Use bin/signer-doctor to quickly validate runtime dependencies (PHP version, required extensions, OpenSSL binary and openssl ts, qpdf, and temporary directory access).
Recommended flow (Brazil/ITI)
- Sign with
--policy=br-itiusingbin/signer-sign. - Validate programmatically with
Signer::validation()->withBrazilPolicy(...). - Inspect final PDF with
bin/signer-inspect --json. - If revocation warnings appear, check
revocation_risk_summaryand endpoint availability for OCSP/CRL URLs.
Running with Docker Compose
This project already includes docker-compose.yml and Dockerfile for the app service.
1) Create external network (first time only)
2) Start the service
3) Install dependencies
4) Run tests
5) Stop environment
Sign using command line (CLI)
The project provides bin/signer-sign, bin/signer-inspect, and bin/signer-doctor.
Basic usage
Example with PAdES Baseline-B and explicit timestamp
Example with DocMDP certification
Example with Brazil policy in CLI
Example with PAdES Baseline-LT
Example with PAdES Baseline-LTA
Options help
Exceptions you should handle
SignerPHP\\Domain\\Exception\\InvalidCertificateExceptionSignerPHP\\Domain\\Exception\\SignProcessExceptionSignerPHP\\Domain\\Exception\\SignerException
Operational requirements
- For RFC3161 timestamping, host
opensslmust supportopenssl ts. - For PDF permissions protection, host
qpdfmust be installed. - If you use the public default TSA, consider availability/SLA for production and prefer a dedicated provider.
Implementation notes
- A digital signature covers specific PDF bytes (
ByteRange). Because of that, operations that rewrite file bytes should run before signing. - Validation checks
ByteRangeintegrity and CMS/PKCS#7 cryptographic validity with OpenSSL. Optionally, it can validate trust chain (enableTrustChainValidation(...)) and Brazil policy (withBrazilPolicy(...)). - PAdES profiles:
- Baseline-B:
SubFilter /ETSI.CAdES.detached - Baseline-T: Baseline-B + RFC3161
- Baseline-LT: Baseline-T +
DSS(Certs,OCSPs,CRLs,VRI) with best-effort evidence collection depending on chain endpoint availability - Baseline-LTA: Baseline-LT + additional archival
Document Timestamp
- Baseline-B:
- Default appearance uses
page = 0and an internal default rectangle; for full control usewithAppearance(...). - Supported PNG bit depths: 1, 2, 4, 8, and 16 bits per channel. 16-bit RGBA and grayscale-alpha PNGs are fully supported including SMask alpha extraction.
- Current PDF parser technical scope:
- Objects with generation different from
0are not supported - Extended object streams are not supported
- Objects with generation different from
Running tests
Code quality
All versions of signer-php with dependencies
ext-openssl Version *
ext-curl Version *
ext-zlib Version *
ext-fileinfo Version *