Skip to content

fix(certificate): accept chains that repeat a certificate name - #9563

Open
hubfc wants to merge 1 commit into
LibreSign:mainfrom
hubfc:bugfix/duplicate-certificate-names
Open

hubfc wants to merge 1 commit into
LibreSign:mainfrom
hubfc:bugfix/duplicate-certificate-names

Conversation

@hubfc

@hubfc hubfc commented Nov 19, 2026

Copy link
Copy Markdown

Resolves: #9562

Summary

A chain may contain two certificates with the same subject (re-issued or cross-signed intermediates, seen with Izenpe). ensureValidStructure() threw on that, so a PDF already signed with such a certificate could not be signed again. orderCertificates() now keeps the first certificate per name instead.

How to test

Sign a PDF whose existing signature embeds two certificates with the same subject. Before: Duplicate certificate names detected. After: it signs.

Validation evidence

  • Unit tests updated: testDuplicateCertificateNamesKeepFirstOccurrence, testChainWithDuplicatedIntermediateIsOrdered
  • php-cs-fixer clean
  • PHPUnit and Psalm not run locally, relying on CI

Checklist

  • I have read and followed the contribution guide.
  • The diff does not contain unrelated refactors or generated changes.
  • Commits follow Conventional Commits where applicable.
  • All commits include the required DCO sign-off.

AI (if applicable)

  • The content of this PR was partially or fully generated using AI

Collapse certificates with the same subject name instead of throwing, so a previously signed PDF whose signature embeds a re-issued or cross-signed intermediate twice can still be signed.

Related issue: LibreSign#9562
Type: Bugfix

Signed-off-by: hubfc <183475170+hubfc@users.noreply.github.com>
@hubfc
hubfc requested a review from a team as a code owner November 19, 2026 15:05
@welcome

welcome Bot commented Nov 19, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request in this repository! ✌️

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signing fails with "Duplicate certificate names detected" when the PDF already has a signature whose chain repeats a certificate name

1 participant