Skip to content

chore: Refactor certificate chain processing with ordering#5584

Merged
vitormattos merged 3 commits intomainfrom
chore/certificate-chain-validation-improvements
Oct 16, 2025
Merged

chore: Refactor certificate chain processing with ordering#5584
vitormattos merged 3 commits intomainfrom
chore/certificate-chain-validation-improvements

Conversation

@vitormattos
Copy link
Member

  • 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.

…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>
@vitormattos vitormattos added this to the Next Major (33) milestone Oct 16, 2025
@vitormattos vitormattos self-assigned this Oct 16, 2025
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap Oct 16, 2025
@vitormattos
Copy link
Member Author

/backport to stable32

@vitormattos
Copy link
Member Author

/backport to stable31

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos changed the title chore: Refactor certificate chain processing with robust ordering alg… chore: Refactor certificate chain processing with ordering Oct 16, 2025
@vitormattos vitormattos merged commit b5b89f4 into main Oct 16, 2025
57 checks passed
@vitormattos vitormattos deleted the chore/certificate-chain-validation-improvements branch October 16, 2025 13:51
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Oct 16, 2025
@vitormattos vitormattos removed this from the Next Major (33) milestone Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant