简体   繁体   中英

Extract digital signature in pdf using python

I need to get the digitally signed signature content like name of signature and signed date and coordinate of the whole signature part.

I tried using different modules like pypdf2, pdfminer and endesive modules, Out of these endesive modules is giving whether the digital signature is there in that pdf document or not.

This is the code base to get whether signature is there or not by using endesive module.

   fname = 'filename'
   data = open(fname, 'rb').read()
   pdf.verify(data)

   The above code gives the following output.
   cert.issuer: OrderedDict([('common_name', 'Srikanth'), ('organization_name', ''), ('organizational_unit_name', ''), ('email_address', 'srikanth@yahoo.com'), ('country_name', 'India')])
cert.subject: OrderedDict([('common_name', 'Srikanth'), ('organization_name', ''), ('organizational_unit_name', ''), ('email_address', 'srikanth@yahoo.com'), ('country_name', 'India')])
Out[13]: (True, True, False)

Please see the below reference link to get the sample digital signature: https://www.globalsign.com/en-in/blog/certifying-vs-approval-signatures-in-adobe/

I need to get the digital signature values like: Person name: Daniel Farrel Signed Date: 2017.10.05 08.44.11 -04'00'

I looked into this a bit, and you seem to be doing everything right. The API to endesive does not return the signers, it uses them internally, but as a caller you do not have access to them [1].

Also, be careful, because it appears that the library does not verify all the signatures, only the first one [2].

[1] https://github.com/m32/endesive/blob/master/endesive/verifier.py#L104

[2] https://github.com/m32/endesive/issues/124

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM