Skip to content

[stable32] chore: Refactor certificate chain processing with ordering#5586

Merged
vitormattos merged 3 commits intostable32from
backport/5584/stable32
Oct 16, 2025
Merged

[stable32] chore: Refactor certificate chain processing with ordering#5586
vitormattos merged 3 commits intostable32from
backport/5584/stable32

Conversation

@backportbot-libresign
Copy link

Backport of PR #5584

…orithm and validation

- **Certificate Ordering (OrderCertificatesTrait):**
  - Implement new leaf-first ordering algorithm with proper chain building
  - Add Distinguished Name normalization for reliable certificate comparison
  - Introduce comprehensive chain validation with `validateCertificateChain()`
  - Handle complex multi-level certificate hierarchies and edge cases
  - Improve error handling with detailed validation messages

- **PDF Signature Processing (Pkcs12Handler):**
  - Refactor `getCertificateChain()` method with extracted helper functions
  - Improve TSA timestamp processing and certificate chain extraction
  - Clean up code organization and remove unnecessary comments
  - Enhance certificate data enrichment from Poppler utilities

- **Test Coverage Improvements:**
  - Add 300+ lines of comprehensive test cases covering real-world scenarios
  - Include banking, corporate, and e-commerce certificate chain examples
  - Add validation tests for complete, incomplete, and invalid chains
  - Refactor Pkcs12Handler tests to focus on public interface without reflection
  - Remove excessive mocking in favor of behavioral testing

- **Code Quality:**
  - Follow best practices by testing only public methods
  - Eliminate reflection-based testing for better maintainability
  - Improve test reliability and reduce brittleness to internal changes
  - Clean up code structure and remove redundant documentation

This enhancement significantly improves certificate chain handling reliability
for digital signature validation in LibreSign, with comprehensive test
coverage ensuring robustness across various PKI scenarios.

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>
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap Oct 16, 2025
@backportbot-libresign backportbot-libresign bot added this to the Next Patch (32) milestone Oct 16, 2025
@vitormattos vitormattos merged commit a32518d into stable32 Oct 16, 2025
56 checks passed
@vitormattos vitormattos deleted the backport/5584/stable32 branch October 16, 2025 18:04
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant