Skip to content

Commit 2df94fe

Browse files
committed
Fix /Contents handling for signatures in encrypted documents
We need to explicitly mark the /Contents string as non-encrypted, otherwise it gets decrypted automatically to gibberish, if a document is encrypted.
1 parent db74c42 commit 2df94fe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/com/itextpdf/rups/model/TreeNodeFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ private static boolean expandSigContentsNode(PdfObjectTreeNode node) {
269269
* themes, but it seems like a reasonable default to use.
270270
*/
271271
final PdfString nodeObject = (PdfString) node.getPdfObject();
272+
// This is important, otherwise /Contents value in encrypted documents
273+
// will be broken...
274+
nodeObject.markAsUnencryptedObject();
272275
final AbstractAsn1TreeNode asn1 = Asn1TreeNodeFactory.fromPrimitive(nodeObject.getValueBytes());
273276
if (asn1 != null) {
274277
/*

0 commit comments

Comments
 (0)