Skip to content

feat: integrate pdf-signature-validator for native validation#7596

Open
vitormattos wants to merge 21 commits intomainfrom
feat/integrate-pdf-signature-validator
Open

feat: integrate pdf-signature-validator for native validation#7596
vitormattos wants to merge 21 commits intomainfrom
feat/integrate-pdf-signature-validator

Conversation

@vitormattos
Copy link
Copy Markdown
Member

@vitormattos vitormattos commented Apr 23, 2026

Summary

  • integrate libresign/pdf-signature-validator into LibreSign via Composer
  • introduce PdfSignatureValidationService to map package validation results to LibreSign payload format
  • update Pkcs12Handler to enrich certificate chain data using native metadata/validation from the package
  • remove pdfsig setup check requirement and keep pdfinfo as poppler fallback check
  • add/adjust unit tests for Pkcs12Handler and PdfSignatureValidationService

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates the libresign/pdf-signature-validator Composer package into LibreSign to perform native (pure-PHP) PDF signature validation, and wires its metadata/validation outputs into LibreSign’s existing certificate-chain payload.

Changes:

  • Add PdfSignatureValidationService to run native validation and translate package results/reasons into LibreSign’s expected format.
  • Update Pkcs12Handler to enrich signature/certificate chain data using native extractor/validator outputs (replacing the previous pdfsig-based Poppler path).
  • Update install checks and unit tests to reflect the new validation flow and dependencies.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/php/Unit/Service/Signature/PdfSignatureValidationServiceTest.php New unit tests for mapping native validator results into LibreSign payload shape.
tests/php/Unit/Service/IdentifyMethod/PasswordTest.php Updates test construction for Pkcs12Handler after constructor dependency changes.
tests/php/Unit/Handler/SignEngine/Pkcs12HandlerTest.php Adds tests for extractor metadata parsing and native validation integration in getCertificateChain().
lib/Service/Signature/PdfSignatureValidationService.php New service wrapping PdfSignatureValidator and translating results/reasons with l10n.
lib/Service/Install/ConfigureCheckService.php Removes the pdfsig setup check, keeping pdfinfo as Poppler fallback check.
lib/Handler/SignEngine/Pkcs12Handler.php Injects native extractor/validation service and uses them to enrich chain leaf data.
lib/Controller/FileController.php Refactors preview mime-fallback redirects and adds broader error handling/logging.
composer.json Adds libresign/pdf-signature-validator dependency.
composer.lock Locks the new package and updates dependency hash.

Comment thread lib/Service/Signature/PdfSignatureValidationService.php
Comment thread composer.json Outdated
Comment thread lib/Handler/SignEngine/Pkcs12Handler.php
Comment thread lib/Handler/SignEngine/Pkcs12Handler.php
Comment thread lib/Handler/SignEngine/Pkcs12Handler.php Outdated
@vitormattos vitormattos force-pushed the feat/integrate-pdf-signature-validator branch 2 times, most recently from 4db8ad1 to 4595c3e Compare April 24, 2026 15:51
vitormattos added 21 commits May 5, 2026 19:47
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The service's validateFromResource() already returns properly formatted
arrays with id, label, isValid, and reason. The localize* methods were
unnecessarily converting numbers back to enums and then back to numbers.

Now Pkcs12Handler uses the validation results directly without the
circular conversion, eliminating code duplication and improving clarity.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- FileController::fetchPreview: add inline type assertions for RedirectResponse
  to specify exact status code (303) when returning null-checked values
- PdfSignatureValidationService: update docblocks for validateFromResource,
  validateFromString, and mapValidationResults to include the 'raw' field
- Pkcs12Handler::extractNativeSignatureMetadata: change return type from
  list<array> to array<int, array{...}> to match actual implementation

All Psalm errors resolved, unit tests still passing.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Update constructor arguments to match the new signature which includes
PdfSignatureValidationService and PdfSignatureExtractor, and removes
the no-longer-used TempManager. Also use real instance of
PdfSignatureExtractor instead of mock since the class is final and
cannot be mocked.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos force-pushed the feat/integrate-pdf-signature-validator branch from 4595c3e to 6015855 Compare May 5, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 0. Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants