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

luozt commented 8 years ago

+1. Waiting for this feature!..

lexcorp commented 7 years ago

When this functionality will be available? What happened to the progress of viveksjain?

@complience Hi, 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 esta repo, but I just Have not Had the time yet.

viveksjain commented 7 years ago

@lexcorp Unfortunately this became a lower priority for me after my previous message. I'll see if I can get around to it, but not going to make any promises I can't keep…

lexcorp commented 7 years ago

I'm trying to compile this version: https://github.com/viveksjain/pdf.js/tree/sig-verify-support When I enter the command: node make generic I get the message: ### Getting extension build number And the compilation process is not performed

How I can resolve this error? I am doing something wrong? Why not end the compilation? unfortunately the console does not send me more information to solve

zambonin commented 7 years ago

@lexcorp If there's still any interest, at least my version is updated enough to compile. :+1:

lexcorp commented 7 years ago

Hi Vivek, yes I´m still interest, thank you...

2016-12-12 12:55 GMT-06:00 Gustavo Zambonin notifications@github.com:

@lexcorp https://github.com/lexcorp If there's still any interest, at least my version is updated enough to compile. 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mozilla/pdf.js/issues/1076#issuecomment-266518165, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfB-LbmIVIrJLnxwJlm8aDITDKh5tWLks5rHZi5gaJpZM4BlvMP .

lexcorp commented 7 years ago

Hey Gustavo, thanks...

2016-12-12 12:55 GMT-06:00 Gustavo Zambonin notifications@github.com:

@lexcorp https://github.com/lexcorp If there's still any interest, at least my version is updated enough to compile. 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mozilla/pdf.js/issues/1076#issuecomment-266518165, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfB-LbmIVIrJLnxwJlm8aDITDKh5tWLks5rHZi5gaJpZM4BlvMP .

linus-amg commented 7 years ago

is there an issue to why the support for digital signatures does not get pulled into pdf.js?

timvandermeij commented 7 years ago

Please follow the discussion in #7702.

rmhrisk commented 7 years ago

I am interested in hearing from people about their use cases for signature verification in PDFjs. Please email me at ryan at peculiarventures.com with your use case.

rmhrisk commented 7 years ago

I would also be interested in hearing your use cases for signing in PDFjs, if you care about that scenario I would also want to hear your use case.

xbqian commented 7 years ago

The sig-verify-support branch of pdf.js does not support IE and firefox perfectly cause WebCrypto can not be get, any idea to deal with it?

rmhrisk commented 7 years ago

You can use https://github.com/PeculiarVentures/webcrypto-liner/blob/master/BrowserSupport.md

WillianSMOliveira commented 7 years ago

Hi folks - Is digital signature verification already working?

marbetschar commented 7 years ago

Same question here: Are digital signatures supposed to work with the latest stable build which can be downloaded from https://mozilla.github.io/pdf.js/getting_started/#download ?

FWIW: I've tested the currently available beta release and can't see any signatures. The only thing I notice is the following line in the browser console:

Warning: Unimplemented widget field type "Sig", falling back to base field type
timvandermeij commented 7 years ago

No, digital signatures are not implemented yet. Anyone who is willing to work on this is welcome to submit a pull request. Thanks.

randiel commented 7 years ago

I want work on this functionality. Someone can give me some guidelines about internal components of PDF.js?

timvandermeij commented 7 years ago

There is some initial work mentioned above that you may be able to use. Make sure to read the wiki for code style and testing instructions.

chitgoks commented 7 years ago

@wolvz : hi which part in viewer.js would that uncomment be? your repository looks to be the original source for pdf.js

most users though would use the stable version files.

FrenchHope commented 7 years ago

As Adobe Acrobat plugin will be obsolete when Mozilla Firefox 59 ESR will be released, features like displaying digital signatures are now really required in pdf.js for enterprise users.

rmhrisk commented 6 years ago

We have implemented a digital signature solution based on PKIjs and PDFjs that is capable of verifying and creating digital signatures. You can see an example of it viewing the US Digital Signature law here.

image

The viewer currently trusts the CAs on the eIDAS Trust List as well the Mozilla trusted S/MIME issuers.

If you encounter any issues email me at ryan@peculiarventures.com with sample files if any.

xrkolovos commented 6 years ago

@rmhrisk can you provide a github repo with a sample code?

rmhrisk commented 6 years ago

@xrkolovos the large majority of the work necessary to make signing and verifying work has been open sourced; it includes https://github.com/PeculiarVentures/PKI.js, https://github.com/PeculiarVentures/ASN1.js, https://github.com/PeculiarVentures/xadesjs/, https://github.com/PeculiarVentures/tl-create, and https://github.com/PeculiarVentures/webcrypto-liner.

We also ended up creating our own PDF library (though we use PDFjs for rendering) so we can create the many different types of signatures PDF allows for. This library will eventually be made public but its not ready for public consumption at this point.

The source to our viewer won't be made public but with the above libraries someone could reproduce verification in their own viewers. We have a basic example of how to do this here: https://pkijs.org/examples/PDFexample.html it would just need to be integrated into your viewers.

Aarbel commented 6 years ago

when will it be merged with pdf.js ?

rmhrisk commented 6 years ago

@Aarbel at this point I don't know when we will find the time to refactor what we have so it could be easily be merged but we would like to see verify finding itself in PDFjs. With that said the PDFjs team has previously expressed concern over the size this feature would represent due to the necessary dependencies. As long as this is a concern it won't make sense to spend the engineering time to do this work.

FrenchHope commented 6 years ago

IMHO, not implementing it before Firefox 59 (ESR) is released would mean the end of Firefox in enterprise if Chrome or Edge can read digital signatures.

rmhrisk commented 6 years ago

@FrenchHope neither chrome of firefox can verify digital signatures.

skellman commented 6 years ago

Any update on this functionality?

Aarbel commented 6 years ago

@Snuffleupagus @yurydelendik @timvandermeij ? :)

yurydelendik commented 6 years ago

As I explained in https://github.com/mozilla/pdf.js/pull/7702#pullrequestreview-4866355, first step will be to create an abstract API that allow to integrate any custom PKI/crypto with PDF.js.

FrenchHope commented 6 years ago

@rmhrisk I dont care about Chrome users. I care about Firefox entreprise users. Many will now use Edge browser or Internet Explorer if Firefox cannot anymore verify digital signatures with Adobe Acrobat Reader plugin.

Many companies migrate to Windows 10 now...

rmhrisk commented 6 years ago

Neither can Edge or IE.

FrenchHope commented 6 years ago

@rmhrisk IE can, with Adobe Acrobat Reader ActiveX.

edit : Edge can display the digital signature but does not inform you of the validity of the signature as Adobe Acrobat Reader does.

rmhrisk commented 6 years ago

ActiveX has been deprecated and will eventually not work.

Edge Does not snow the digital signature it shows the image in an annotation regardless of the status of the signature.

LeoDupont commented 6 years ago

Hello, what is the current status of this feature?

timvandermeij commented 6 years ago

It's not being worked on right now, but recently someone showed interest in the code above on IRC. The first step would really be https://github.com/mozilla/pdf.js/issues/1076#issuecomment-374244765.

MaxMayoris commented 6 years ago

Hi, do you have any expected date like Dic 2018 or maybe 2019 to release that API? Thanks for the pdf viewer by the way, works excellent

brianholle commented 6 years ago

I wanted to implement the simple fix that was mentioned above... Commenting out the following lines:

// Hide signatures because we cannot validate them.
          if (data.fieldType === 'Sig') {
              _this2.setFlags(AnnotationFlag.HIDDEN);
          }

However, this is causing an error in the console (from util.js:418). Does anyone know what causes this issue (Other than the fact that the signature is now displayed)?

Error:

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': function nonSerializableClosure() {
          return nonSerializable; // creating closure on some variable
        } could not be cloned.
    at eval (http://localhost:8888/src/shared/util.js:418:20)
strazovan commented 6 years ago

@brianholle I tried and if you comment out

 if (data.fieldType === 'Sig') {
      warn('unimplemented annotation type: Widget signature');
     // this.setFlags(AnnotationFlag.HIDDEN);
    }

in built pdf.worker.js, then it works.

It would be nice to at least provide option for this. In our case for example, we already know that signature is valid, because we validate signatures before.

brianholle commented 6 years ago

@strazovan Thanks, and agreed. I created a flag that can be set in default_preferences.json. I can post those changes if you are interested!

hanxiaodao commented 6 years ago

@brianholle Hello, I'll follow your example. Annotated with this code, chrome displays normally, but the digitally signed image in IE browser obscures the text.

brianholle commented 6 years ago

@hanxiaodao You are saying that when commenting out the blocking code:

 if (data.fieldType === 'Sig') {
      warn('unimplemented annotation type: Widget signature');
      // this.setFlags(AnnotationFlag.HIDDEN);
 }

You have issues displaying in IE?

hanxiaodao commented 6 years ago

@brianholle Thank you for your reply. I follow your example,but there was a problem in IE 11. The red chapter of digital signature obscures the text content. This is the effect on chrome. chrome pic This is the effect on IE11. ie11_pic

quarryman commented 5 years ago

Can we get any estimations from maintainers if any efforts will be put into signatures verification?

timvandermeij commented 5 years ago

It's not a priority for us right now, but if anyone wants to contribute this (see the comments above for how it should be implemented), then we are willing to look into integrating this in PDF.js.

Bartonitz commented 5 years ago

We are also interested in showing digital signatures which can not be verified. Please, see an example attachted. Verpf-Erklärg-Bundesdatenschutz-Sig.pdf

lyre2468 commented 5 years ago

when I comment: if (data.fieldType === 'Sig') { // this.setFlags(AnnotationFlag.HIDDEN); }

error:

message_handler.js:87 Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': #<DedicatedWorkerGlobalScope> could not be cloned.
    at eval (http://localhost:8888/src/shared/message_handler.js:87:21)

and why don't render the "div. annotationLayer"

vlastimilmaca commented 5 years ago

Hahaa , I know this one ... it's related to #10350 . So you need to comment this line: // this.setFlags(AnnotationFlag.HIDDEN); and add this line after that: data.fieldValue = null;

ghost commented 5 years ago

How to config the pdf or pdf_viewer to enable the util.js that control the seal displayed switch? There are some AnnotationFlag options in util.js file like INVISIBLE 0x01、HIDDEN 0x02. I modify the AnnotionFlag in pdf.worker.js from HIDDEN to PRINT. Can I config them without this way?

KentuckyMC commented 5 years ago

Should be a very nice feature. Hopefully this would be a feature soon!