pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evert-Jan de Bruin <evert-jan.de.br...@caci.nl>
Subject Signed PDF with non-encrypted headers causes issue in PDFBox 2.0.9
Date Tue, 24 Apr 2018 10:48:14 GMT

For my project I have to merge PDF files together. This usually works fine, but it does not
always work with digitally signed PDF files.

Simply a load() of the document will already fail with InvalidBlockSizeException. Here is
an example document: https://ufile.io/mgshz

I went into the PDFBox code, and the issue seems to be that it detects AES encryption in the
PDF due to the digital signature, but then assumes everything is encrypted and needs to be
decrypted. However, the headers are *not* encrypted so decryption fails.

I can get it all to work by going to PDFParser.java and disabling these three lines in prepareDecryption():

//                securityHandler = encryption.getSecurityHandler();
//                securityHandler.prepareForDecryption(encryption, document.getDocumentID(),
//                        decryptionMaterial);
//                accessPermission = securityHandler.getCurrentAccessPermission();

However, this is of course very ugly as decryption is now totally disabled. I also get warnings
about offset issues but the end result seems fine.

Is there a more elegant solution or is this really a bug?

It seems to be a repetition of https://issues.apache.org/jira/browse/PDFBOX-3229 but this
should have been fixed in 2.0.0, however, it still occurs in 2.0.9


Evert-Jan de Bruin



De Ruyterkade 7
1013 AA Amsterdam

088 - 654 3594

This electronic message contains information from CACI BV, which may be confidential, proprietary,
privileged or otherwise protected from disclosure. The information is intended to be used
solely by the recipient(s) named above. If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this transmission or its contents
is prohibited.
If you have received this transmission in error, please notify the sender immediately and
delete all copies of this message.

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message