Verifying a pdf signature raises an error when accessing SignerInfo native
See original GitHub issueI followed the example for verifying a pdf signature and I have something like this:
pdf_file_path = "/workspaces/test.pdf"
data = open(pdf_file_path, 'rb').read()
certificates = (
open("/workspaces/certificates/pki.pem", 'rt').read(),
open("/workspaces/certificates/pki-chain.pem", 'rt').read()
)
(hashok, signatureok, certok) = pdf.verify(data, certificates)
print('signature ok?', signatureok)
print('hash ok?', hashok)
print('cert ok?', certok)
This should be pretty straight forward. I read the pdf, I open the certificates and then I ‘pdf.verify’ to see that everything is in order.
pdf.verify, at one point calls this: signed_data = cms.ContentInfo.load(bcontents)['content'].native
which makes ans1crypto raise this error File "/home/vscode/.local/lib/python3.9/site-packages/asn1crypto/core.py", line 4060
, in native raise e repeatedly until it gets to
ValueError: Unknown element - context class, constructed method, tag 0
while parsing asn1crypto.core.Sequence
while parsing asn1crypto.cms.SetOfAny
while parsing asn1crypto.cms.CMSAttribute
while parsing asn1crypto.cms.CMSAttributes
while parsing asn1crypto.cms.SignerInfo
I manually tried to replicate what pdf-verify.py does and I noticed that this would work if it didn’t call native and would go directly for the signature:
signature = signed_data['signer_infos'][0].native['signature'] # doesn't work
signature = signed_data['signer_infos'][0]['signature'] # works
I hope this is the place to post issues with the library. If not, I am sorry.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Verifying a pdf signature with Endesive raises an error when ...
Instead of addressing signer data info like this: signature = signed_data['signer_infos'][0].native['signature'].
Read more >Releases · m32/endesive - GitHub
en-crypt, de-crypt, si-gn, ve-rify - smime, pdf, xades and plain files in pure ... Verifying a pdf signature raises an error when accessing...
Read more >Validating digital signatures, Adobe Acrobat
Follow these steps to set up digital signature validation, certify a PDF, timestamp a document, ad validate or remove a digital signature in ......
Read more >Release 0.16.0-dev1 Matthias Valvekens - pyHanko
Signing PDF files using pyHanko can be very simple or somewhat ... In particular, as_pdf_object() always raises an error, since the ...
Read more >Release v2.0.9 · m32/endesive · GitHub
Verifying a pdf signature raises an error when accessing SignerInfo native #122. Assets. 2. Source code (zip) · Source code (tar.gz). Footer.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
try next version v2.0.9
I checked this and changing:
signature = signed_data['signer_infos'][0].native['signature']
tosignature = signed_data['signer_infos'][0]['signature'].native
provides a valid signature.
Since this is normally part of verifier.py, how should I work around this problem to be able to run
pdf.verify(...)
?