Skip to content

pkcs7 fix: retain certificates after SignedData encode - #11062

Open
danielinux wants to merge 1 commit into
wolfSSL:masterfrom
danielinux:fix-pkcs7-reencode-drops-certificates
Open

pkcs7 fix: retain certificates after SignedData encode#11062
danielinux wants to merge 1 commit into
wolfSSL:masterfrom
danielinux:fix-pkcs7-reencode-drops-certificates

Conversation

@danielinux

Copy link
Copy Markdown
Member

Description

PKCS7_EncodeSigned() freed the object's certificate-list nodes after a successful encode while leaving the signer fields populated. Reusing the object then emitted SignedData without certificates, requiring external signature verification.

Keep the list until wc_PKCS7_Free(), which already handles its cleanup.

Testing

Discovered in MC/DC campaign part 5 #11039

PKCS7_EncodeSigned() freed the object's certificate-list nodes after a successful encode while leaving the signer fields populated. Reusing the object then emitted SignedData without certificates, requiring external signature verification.

Keep the list until wc_PKCS7_Free(), which already handles its cleanup.
Copilot AI lite review requested due to automatic review settings August 5, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes PKCS#7 SignedData encoding object reuse by stopping PKCS7_EncodeSigned() from freeing the internal certificate-list nodes after a successful encode. This keeps certificate inclusion consistent across repeated encodes until the object is explicitly cleaned up via wc_PKCS7_Free().

Changes:

  • Remove the post-encode call to wc_PKCS7_FreeCertSet(pkcs7) in PKCS7_EncodeSigned().
  • Ensure the certificate list remains available for subsequent encodes and is only cleaned up in wc_PKCS7_Free().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danielinux danielinux self-assigned this Aug 5, 2026
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.

2 participants