mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.02k stars 9.93k forks source link

Digital signatures in pdf.js #1076

Closed soa-x closed 3 years ago

soa-x commented 12 years ago

Hi! We are interested about when or if you´re going to implement the Signature Data View (Xades, Pades & Cades) in the PDF viewer (PDF.js)

Kind Regards

Alejandro Pinedo, SOA-X

brendandahl commented 12 years ago

There are currently no imminent plans to implement this feature. We haven't seen it come up much so it hasn't been a priority. We're always looking for more contributors though, so we'd welcome any patches to add this feature. If you're interested in adding it feel free to stop by our IRC channel(#pdfjs irc.mozilla.org) if you have questions.

Brendan

fermo111 commented 10 years ago

Hi

what is the present state on the implementation of this feature?

Thanks

yurydelendik commented 10 years ago

@fermo111 Not implemented yet, but I will be glad to coach somebody who is willing to take this task.

wolvz commented 10 years ago

@yurydelendik I'm interested in implementing the feature of presenting digital signatures of PDF files in pdf.js. How can I contact you?

yurydelendik commented 10 years ago

@wolvz please find me at IRC irc.mozilla.org channel #pdfjs (that's simplest) or join any of our public meetings to coordinate stuff.

wolvz commented 10 years ago

I'm trying to implement SigWidgetAnnotation (like TextAnnotation, LinkAnnotation), in annotation.js, for supporting digital signatures in pdf.js. The signature is showing up in the pdf viewer, and I already can extract and verify the certificates embbeded in the DER-encoded PKCS7 object... Now I'm moving into the next step, which is to verify the message digest of the file. For that I need to have access to the file contents... I dont' know if it's possible or not to have access to that from annotation.js, but I can't figure it out. The best I could do was to get the contents in core.js using:

var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream',[]); var dataPromises = Promise.all([contentStreamPromise]); dataPromises.then(function(data) { var contentStream = data[0]; var contents = contentStream.str.bytes; return contents; });

Can someone please enlighten me on what is the best way to get file contents in annotation.js? Thanks in advance...

yurydelendik commented 10 years ago

https://forums.adobe.com/message/6660799

ashrafulkarim commented 10 years ago

wolvz, any progress in this regard?

corynewey commented 9 years ago

@yurydelendik @wolvz I am extremely interested in the digital signature display feature. I cloned wolvz's repository and built the code but when I try to use it, I'm getting a promise rejection with this error: "require is not defined". Could anyone explain what would cause that error and how I could fix it? Also, I am very willing to continue the work on this feature. I've worked with pdf's in Java via the iText library but working with them in javascript is something I've never tried before. Could someone direct me to some documentation/tutorial that could get me pointed in the right direction so that I can figure out where to start as I try to move this feature further down the field?

mrpandya007 commented 9 years ago

I am confused. What i have to do in my pdf.js library to show digital signature pdf in pdfJS

mrpandya007 commented 9 years ago

untitled

This signature and certificate both showing in pdf.. but when i open it in pdf.js it wont showing there.

wolvz commented 9 years ago

@mrpandya007, the digital signature doesn't show because the developers chose to hide it until they have signature verification feature working. If I recall, if you want them simply to show up you have to comment lines 389 to 392 here: https://github.com/mozilla/pdf.js/blob/master/src/core/annotation.js#L389 Not sure though, and I can't test it right now.

mrpandya007 commented 9 years ago

@wolvz, Thanx for the response but its already commented. PLease look into this,, Crystal report's generated pdf signature is not showing but DevExpress generated pdf is showing it properly

mrpandya007 commented 9 years ago

Please answer me .... what i have to do.. I can give you that pdf to test

timvandermeij commented 9 years ago

There is no good support for digital signatures yet, so this will have to be implemented.

mrpandya007 commented 9 years ago

How many days it will take to fix this problem of digital signature because we are dependent on your lib.

timvandermeij commented 9 years ago

It might take a long time as this feature will have to be developed by someone and there are currently higher-priority issues.

mrpandya007 commented 9 years ago

heading

Why i am facing such issue of "=" sign in Headings, only in pdf.js, after downloading the file it gone. any solution please. It is happens only in telerik generated pdf.

timvandermeij commented 9 years ago

@mrpandya007 Please do not post unrelated issues inside other issues. Open a separate issue for that problem.

ssindelar commented 9 years ago

I also encountered the same problem. While I don't necessarily require the signature validation it would be in my case sufficient enough to just show the signature image. Maybe till signature validation is implemented instead of not showing the image it would be better to show the image and annotate it with a small text that says something like "Signature validation not implemented. Signature status unknown"? So at least visiually the pdf would show what you would expect.

landyg commented 9 years ago

Is there a timeline for when this issue will be addressed? Or should we consider another product? pdfjsissue

timvandermeij commented 9 years ago

Nobody is working on this yet as far as I know, so if someone is willing to work on this, feel free to submit a PR.

DORNINEM commented 9 years ago

Hi, A PDF.JS version that is able to only displaydigital signature fields should be enough for many users... Is there any "fork" who is able to do this ? Regards

wolvz commented 9 years ago

@DORNINEM you just need to comment out the piece of code that hides the signature annotations. But anyway, here is the fork you asked for: https://github.com/wolvz/pdf.js

DORNINEM commented 9 years ago

@wolvz !! Thanks a lot. I'm wondering why this feature is not in the official version, as it wokrs very fine. I tested with some of my signed PDF files (from 1 to 6 different signature fields) and the result is perfec ! I'm really sure that the real need is to display these fields, not to validate the signature. Signature validation is best done on the server side as it require some times certificates not installed on a local certificate repository.

maximlefebvre commented 9 years ago

Hello,

Someone can explain which line we have to comment or uncomment to allow pdf.js to display the digital signature ?

Thanks for all information :)

timvandermeij commented 9 years ago

@maximlefebvre According to https://github.com/wolvz/pdf.js/commit/7df3f4fe6e21b888358fd7718cb15e3c266ba066, that should be enough to let PDF.js display the signature. Note however that this has not been verified by the PDF.js team as a stable solution (hence why it is not in the official codebase yet), but it might work as a temporary solution.

viveksjain commented 8 years ago

We are interested in implementing signature verification. It seems @wolvz started work on this but didn't complete it - do you have any partial code that we could work on top of?

amolc commented 8 years ago

@wolvz , can you please help us by making a small note to understand your repo. I am unable to understand how to start checking your code. We are trying to implement signature and we may be able to complete your project and help the community.

rmhrisk commented 8 years ago

We have implemented both signing and signature verification of PDFs in browser using https://pkijs, you can see an early signature verification demo here: https://pkijs.org/examples/PDFexample.html we have not yet integrated with PDFjs but will be doing that in the not so distant future. Our intention is to release most of this as OSS and give back any changes to PDFjs that are necessary to make integration smooth.

viveksjain commented 8 years ago

Awesome, thanks @rmhrisk! However, I am not sure how to create a CA bundle file. Do you have details on how to do so? I would imagine when this is integrated with pdf.js it would be more "plug and play" where it comes with Adobe Root CA by default and can verify the certificate chain, right? And do you have a expected timeline for pdf.js integration? Your work is greatly appreciated!

rmhrisk commented 8 years ago

There is one here: http://curl.haxx.se/ca/cacert.pem and one checked into the repository under samples.

There is a tool to create one here: https://github.com/PeculiarVentures/tl-create

rmhrisk commented 8 years ago

I can't share an ETA at this time, we are limited on resources and this is important to us but we need to finish some more complex parts first.

viveksjain commented 8 years ago

I tried the one you linked to, as well as some certificates I tried to extract from the PDF using Adobe Reader, but I always get the error "TypeError: Cannot read property 'signature_time_stamp' of undefined" (in Safari/Chrome stable/Chrome canary).

I happen to have some time this coming week, so let me know if I can help with the merging into pdf.js in any way.

rmhrisk commented 8 years ago

That sample only supports basic signatures, no timestamping or LTV at this time. Feel free to ping me at rmh at unmitigatedrisk dot com

viveksjain commented 8 years ago

Ah, I see. For reference, finally got it to work in Chrome/Firefox (but not Safari, which apparently only supports prefixed WebCrypto) using this CA bundle and this PDF file.

rmhrisk commented 8 years ago

Yes that too, its not only the prefixed issue but they also only support enough webcrypto to handle netflix drm cases. For example they dont let you export the public key for a keypair you generate!? This is a good resource for verifing browser support - https://diafygi.github.io/webcrypto-examples/

mrpconnor commented 8 years ago

@viveksjain Can you confirm how you got it working in Chrome/Firefox

I've tried using the development plugin in firefox however it still appears to fail to show signatures. http://mozilla.github.io/pdf.js/extensions/firefox/pdf.js.xpi

rmhrisk commented 8 years ago

@complience he got the sample code located at https://pkijs.org/examples/PDFexample.html working not PDFjs

viveksjain commented 8 years ago

Hi @complience, I have a proof-of-concept working at https://github.com/viveksjain/pdf.js/tree/sig-verify-support. You can try it by using git clone --recursive https://github.com/viveksjain/pdf.js.git. With a little bit more work it should be ready for a pull request into this repo, but I just haven't had the time yet.

marklagendijk commented 8 years ago

@viveksjain nice! What is still needed before it is ready for a pull request?

robinblandford-d4h commented 8 years ago

+1 Delighted to get this functionality.

dgbeck commented 8 years ago

Yes this will be a great value add to the community, opening the door for many use cases. Thank you!!

xrkolovos commented 8 years ago

+1 for this functionality

tmetzke commented 8 years ago

+1 for this functionality

timvandermeij commented 8 years ago

To all the people above, please make use of GitHub's new +1 reaction button instead of adding comments here.

gimoteco commented 8 years ago

+ 1 for this functionallity

jimmy-collazos commented 8 years ago

👍 + 1 for this functionallity

timvandermeij commented 8 years ago

Again, please use GitHub's reaction button on the top comment to upvote this functionality, which will help us prioritize the issue. Adding "+1" comments causes unnecessary notifications for the developers.

linus-amg commented 8 years ago

"TypeError: Cannot read property 'signature_time_stamp' of undefined" using the branch of @viveksjain