Verifying PDF Signature in Java using Bouncy Castle and PDFBox
I am trying to verify digitally signed PDF document in Java. I'm using Apache PDFBox 2.0.6 to get the signature and the original PDF that was signed, then I'm using Bouncy Castle to verify detached signature(calculate the hash of the original file, verify the signature using signer's public key and compare the results). I read this article and tried to get the signature bytes and the original PDF bytes using this code: PDDocument doc = PDDocument.load(signedPDF); byte[] origPDF = doc.getSignatureDictionaries().get(0).getSignedContent(signedPDF); byte[] signature = doc.getSignatureDictionaries(