m32 / endesive

en-crypt, de-crypt, si-gn, ve-rify - smime, pdf, xades and plain files in pure python
MIT License
239 stars 92 forks source link

Verify PDF Digital certificate #121

Closed GenVr closed 2 years ago

GenVr commented 2 years ago

Hi, I aim to check if there is a digital signature in a pdf. Inspired by the method in pdf-verify.py, some PDFs work for me, but others don't. I have this assertion error:

assert n != -1 and start != -1 and stop != -1

All this three are -1, because n = pdfdata.find(b"/ByteRange") and ByteRange is not in the bytes of the PDFs.

How can I solve? I just need to check if the pdf has a digital signature. Thank you.

m32 commented 2 years ago

If there is no object in the file: /Type /Signal /Filter /Adobe.PPKLite /SubFilter /adbe.pkcs7.detached /ByteRange [int int int int] /Contents <....

This means for endesive that the file is unsigned. Endesive only knows one way to sign a PDF

GenVr commented 2 years ago

This means for endesive that the file is unsigned. Endesive only knows one way to sign a PDF

Are there other methods to recognize if a pdf has a digital signature? Thanks

m32 commented 2 years ago

I wrote endesive with this document in mind: https://www.adobe.com/devnet-docs/etk_deprecated/tools/DigSig/Acrobat_DigitalSignatures_in_PDF.pdf

Now it is deprecated :(