Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital signatures in pdf.js #1076

Open
soa-x opened this issue Jan 13, 2012 · 105 comments

Comments

@soa-x
Copy link

commented Jan 13, 2012

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

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2012

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

This comment has been minimized.

Copy link

commented Feb 28, 2014

Hi

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

Thanks

@yurydelendik

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2014

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

@wolvz

This comment has been minimized.

Copy link

commented Mar 31, 2014

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

@yurydelendik

This comment has been minimized.

Copy link
Contributor

commented Mar 31, 2014

@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

This comment has been minimized.

Copy link

commented May 31, 2014

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

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2014

@ashrafulkarim

This comment has been minimized.

Copy link

commented Sep 9, 2014

wolvz,
any progress in this regard?

@brendandahl brendandahl modified the milestones: 2014 Q3, 2014 Q4 Oct 2, 2014

@brendandahl brendandahl modified the milestone: 2014 Q4 Jan 8, 2015

@corynewey

This comment has been minimized.

Copy link

commented Jan 31, 2015

@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

This comment has been minimized.

Copy link

commented Mar 18, 2015

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

@mrpandya007

This comment has been minimized.

Copy link

commented Mar 18, 2015

untitled

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

@wolvz

This comment has been minimized.

Copy link

commented Mar 18, 2015

@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

This comment has been minimized.

Copy link

commented Mar 18, 2015

@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

This comment has been minimized.

Copy link

commented Mar 25, 2015

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

@timvandermeij

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2015

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

@mrpandya007

This comment has been minimized.

Copy link

commented Mar 27, 2015

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

@timvandermeij

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2015

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

@mrpandya007

This comment has been minimized.

Copy link

commented Mar 30, 2015

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.

@FrenchHope

This comment has been minimized.

Copy link

commented Mar 29, 2018

@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

This comment has been minimized.

Copy link

commented Mar 29, 2018

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

This comment has been minimized.

Copy link

commented Jul 2, 2018

Hello, what is the current status of this feature?

@timvandermeij

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2018

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 #1076 (comment).

@MaxMayoris

This comment has been minimized.

Copy link

commented Aug 18, 2018

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

This comment has been minimized.

Copy link

commented Aug 22, 2018

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

This comment has been minimized.

Copy link

commented Sep 3, 2018

@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

This comment has been minimized.

Copy link

commented Sep 11, 2018

@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

This comment has been minimized.

Copy link

commented Sep 13, 2018

@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

This comment has been minimized.

Copy link

commented Sep 13, 2018

@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

This comment has been minimized.

Copy link

commented Sep 14, 2018

@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

This comment has been minimized.

Copy link

commented Nov 14, 2018

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

@timvandermeij

This comment has been minimized.

Copy link
Contributor

commented Nov 14, 2018

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

This comment has been minimized.

Copy link

commented Dec 10, 2018

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

This comment has been minimized.

Copy link

commented Dec 12, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

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;

@864534182

This comment has been minimized.

Copy link

commented Mar 25, 2019

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?

@jvalst

This comment has been minimized.

Copy link

commented Mar 26, 2019

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

stefanmaric added a commit to stefanmaric/pdf.js that referenced this issue Apr 14, 2019

Expose signature data to the main thread via WidgetAnnotation
A Signature widget is not available since it makes no sense to display
a signature if it cannot be validated.

But exposing the signature allows the PDF to verified outside of
PDF.js, but taking advantage of PDF.js' parsing.

See: Issue mozilla#1076
See: PR mozilla#7702
See: PR mozilla#10350
@Herb-sh

This comment has been minimized.

Copy link

commented Apr 24, 2019

Anyone knows any reliable workaround to this? Editing built files might only work locally or for testing purposes but no more than that.

@xrkolovos

This comment has been minimized.

Copy link

commented May 19, 2019

Is pdfjs a dead project? Why they don't implement for so many years the most wanted features??

image

@jvalst

This comment has been minimized.

Copy link

commented May 20, 2019

I want to achieve that I can show a small notification somewhere in PDF.js that the digital signatures are not validated. I get that working on Chrome, but not on the other browsers. It's far from the best case, but we really want to show those signatures even if they're not 100% validated. I've tried to change the pdf.worker.js code at the piece where this.setFlags(AnnotationFlag.HIDDEN); stood. I've added a "document.getElementbyId" construction where I show my container when there is 1 or more signatures. But all the browsers (except chrome) don't recognize "document". Is there an option to add a property on the document or something, and use that in the viewer.js? There are more constructions with getElementbyId. Any help would be awesome.

@rmhrisk

This comment has been minimized.

Copy link

commented Aug 14, 2019

We recently wrapped our viewer that supports signature verification into a web component and iframe; you can find out more about how to use it here: https://verify.ink/

@lexcorp

This comment has been minimized.

Copy link

commented Aug 15, 2019

rmhrisk that’s great!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.