You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PDF.js now displays digital signatures, but doesn't validate them, which is comparable to what other PDF viewers do. However, it would be good if we can also implement validation for them, so this is a tracking issue for that.
Reacted by Luka Teras, Thanarat Kuawattanaphan, Nikhil Nigade, Andrés, Tomáš Zelina, Felix Eckhofer, VaiTon, Aleksandr Gavrilov, AL.exe, Wu Jason and 16 more
It's pretty easy to implement (regarding existing js libraries) BUT the main concern is about having something the user can trust because here everything is a matter of trust.
So if we rely on a third party js lib, it means that we must control everything happening in this lib to avoid a bug or injection of bad code or whatever: it's time consuming (any change in the lib could have an impact in every other place), it requires particular skills (crypto + js skills), so it's likely a bad solution.
For this reason, we think that a good solution (at least for the build-in pdf viewer) is to rely on NSS (https://hg.mozilla.org/projects/nss), expose what is needed (from the crypto's side) to javascript and let the experts (crypto team, cc @beurdouche, @mozkeeler) decide what's the best way to implement that stuff.
Reacted by Jonas Jenwald, Tim van der Meij, Ryan Hurst and Stamo Gochev
@CetinSert the complication isn't crypto, it is support for certificate decoding, trust stores, path validation, timestamping, CMS, etc so, unfortunately, webcrypto isn't enough. Made https://pkijs.org/ to provide these things on top of WebCrypto but in Mozilla land, NSS would be a natural choice as it has many, but not all of these things.
There is the question of trust store contents, this gets more complicated, the Mozilla Trust Store does have a S/MIME policy but nothing for document signing. It also lacks the necessary timestamping and numerous attributes one needs when doing a full implementation so there is still a non-trivial amount of work to do with this approach.
Just bumped into this. Is there any 'simple' way to just display a 'warning' onscreen that the shown signatures are not validated? Now there is only a console.warn, but maybe just show something inside the pdf.js as overlay or something, to warn users that the signatures shown are not displayed? Any Idea where I can put something like this in the code?
Reacted by Stamo Gochev , Wout Mertens, Beata Jaroszewska and Alex Ehlke
PSA: If you want to test this feature on the latest FF nightly 156.0a1 with PDF.js 6.3.72, you have to set the pdfjs.enableSignatureVerification to true in about:config.
PSA: If you want to test this feature on the latest FF nightly 156.0a1 with PDF.js 6.3.72, you have to set the pdfjs.enableSignatureVerification to true in about:config.
trust and trust:src on <pdf-file> set which certificate authorities you trust. A signature shows verified only if its certificate chain ends at one of them.
Nothing is trusted by default. Browsers don't give pages their root certificates, and the Adobe and EU signing trust lists aren't built in. With no anchors, an intact signature still shows untrusted ("no trust anchors are configured").
trust takes the certificates inline: one or more PEM certificates, a PEM PKCS#7 bundle, or bare base64.
trust:src takes exactly one URL, resolved against the page and fetched by the browser. Relative, //host/…, https:, data: and blob: all work, and the file can be PEM, a DER .cer/.crt, or a .p7b. Cross-origin URLs need CORS.
If the fetch fails, each signature gets a TRUST_SOURCE_FAILED warning and comes out untrusted. The next verification tries again.
Using both trusts all the certificates from both.
Roots or intermediates: an anchor can be a root or an intermediate CA. Trusting an intermediate trusts only what it issued. A certificate marked "not a CA" can't be an anchor, so you can't trust one signer's certificate on its own.
Changing either attribute re-checks the signatures without reloading or re-rendering the PDF. Changing both at once triggers a single re-check. Results arrive in the signed attribute and the verify event, and from JavaScript the attributes are file.trust and file.trustSrc.
Online OCSP/CRL checks (through the proxy) run only for chains that reach an anchor. An untrusted PDF therefore can't make the browser fetch URLs.
My custom HTML elements also support maintained SVG backend that builds upon what PDF.js abandoned a while ago. Testing it every month against issues from PDF.js and PDFium! It also supports PDFium and does all the rendering off the main thread!
and before someone starts scaremongering with "oh it's all in the frontend, we can't trust this" nonsense, the platform where I am building my custom HTML elements does have adjacent service/edge workers so signature verifications can be offloaded to the edge with zero user access. As for any unasked for concerns of people tampering with the pages in the frontend, obfuscator.io × closed shadow roots × MutationObserver and I am done before you can even open your mouth to complain!
Sorry, not sorry! Security guys act all snobby and annoyingly look down on people and I can't just shut up and take it anymore! Just because you have a browser (Firefox), does not mean the open web cannot be secured! I can even do open-source code delivered with obfuscation with proofs that what you get obfuscated for tamper-proofing IS exactly the open-source code byte for byte.
Activity
calixteman commentedon May 9, 2021
It's pretty easy to implement (regarding existing js libraries) BUT the main concern is about having something the user can trust because here everything is a matter of trust.
So if we rely on a third party js lib, it means that we must control everything happening in this lib to avoid a bug or injection of bad code or whatever: it's time consuming (any change in the lib could have an impact in every other place), it requires particular skills (crypto + js skills), so it's likely a bad solution.
For this reason, we think that a good solution (at least for the build-in pdf viewer) is to rely on NSS (https://hg.mozilla.org/projects/nss), expose what is needed (from the crypto's side) to javascript and let the experts (crypto team, cc @beurdouche, @mozkeeler) decide what's the best way to implement that stuff.
mozkeeler commentedon May 10, 2021
Does this need to be in NSS? Does pdf.js have access to the gecko runtime?
CetinSert commentedon May 18, 2021
Does
window.crypto.subtlenot expose the required primitives to do this without 3rd-party dependencies?(I think/support that non-browsers environments are not an official target for the project but for anyone concerned about support in Node, see https://nodejs.org/api/webcrypto.html#webcrypto_class_subtlecrypto .)
rmhrisk commentedon May 18, 2021
@CetinSert the complication isn't crypto, it is support for certificate decoding, trust stores, path validation, timestamping, CMS, etc so, unfortunately, webcrypto isn't enough. Made https://pkijs.org/ to provide these things on top of WebCrypto but in Mozilla land, NSS would be a natural choice as it has many, but not all of these things.
There is the question of trust store contents, this gets more complicated, the Mozilla Trust Store does have a S/MIME policy but nothing for document signing. It also lacks the necessary timestamping and numerous attributes one needs when doing a full implementation so there is still a non-trivial amount of work to do with this approach.
earthchie commentedon May 24, 2021
For anyone who's looking for a temporary solution while waiting for official support from this project.
This repo might help you: https://github.com/rootca-id/pkiwebsdk/blob/master/src/pdf.js
mozkeeler commentedon May 24, 2021
@calixteman just making sure you saw this ^
calixteman commentedon May 24, 2021
@mozkeeler, thanks for reminding me.
I'm not crypto expert at all, but in poppler they're using some NSS stuff to implement part of signature validation so I guess we would need too.
And yes we've access to gecko runtime, for example:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#268
marco-c commentedon Jun 23, 2021
@andrewyu7575 there are no short term plans to implement digital signature validation, but we'd be happy to accept a contribution.
KentuckyMC commentedon Feb 4, 2022
Just bumped into this. Is there any 'simple' way to just display a 'warning' onscreen that the shown signatures are not validated? Now there is only a console.warn, but maybe just show something inside the pdf.js as overlay or something, to warn users that the signatures shown are not displayed? Any Idea where I can put something like this in the code?
lexcorp commentedon Apr 14, 2023
lexcorp commentedon May 9, 2023
lexcorp commentedon Dec 26, 2023
Hello, what is required for this to move forward?
What would the roadmap be?
Could you list the requirements to know how we can contribute?
13 remaining items
marco-c commentedon Mar 16, 2026
The backend functionality for this, using crypto, is basically done in Firefox, but we need a good UX design to implement.
lexcorp commentedon May 8, 2026
Maybe something like this:
https://hancock.ink/
lexcorp commentedon Jul 4, 2026
Hi, in which version or release will this improvement be available? I'm eager to try it out...
ousia commentedon Jul 4, 2026
I’m just another user (who would like to test this implementation).
Releases tend to be and the end of the month (https://github.com/mozilla/pdf.js/releases), so this commit may be included in the release of the end of July.
Which “Firefox” version may include the feature is unknown to me. According to https://whattrainisitnow.com/calendar/, although version 154 wouldn’t be completely impossible, probably version 155 (due to 09.15.2026) would be a safer bet.
If they choose an “intermediate” release (Firefox 152 includes PDF.js 6.0.109), I don’t know where that info may be publicly available.
Just in case it might help.
feat(pdf): enable pdf.js signature editor
softboy99 commentedon Jul 30, 2026
We tried v6.2.108, However, without finding any UI about signature.
we need something like this:
mdindoffer commentedon Aug 17, 2026
PSA: If you want to test this feature on the latest FF nightly 156.0a1 with PDF.js 6.3.72, you have to set the
pdfjs.enableSignatureVerificationtotrueinabout:config.williamdes commentedon Oct 1, 2026
https://www.sautinsoft.com/products/pdf/help/net/Code%20samples/CSharp/07.%20Securing%20and%20signing/05.%20Read%20Signature%20Properties/digital%20signature.pdf
Thanks for the tip, it works !
LibreWolf 156.0.1-1
Also https://www.tecxoft.com/samples.php but none are valid
afife commentedon Oct 1, 2026
This is great! How can we add CA certificates to the trust anchors?
CetinSert commentedon Oct 1, 2026
Been waiting since 2021-05-18 ...
My custom HTML elements for PDFs now have signature verification built-in!
@afife @timvandermeij
trustandtrust:srcon<pdf-file>set which certificate authorities you trust. A signature shows verified only if its certificate chain ends at one of them.trusttakes the certificates inline: one or more PEM certificates, a PEM PKCS#7 bundle, or bare base64.trust:srctakes exactly one URL, resolved against the page and fetched by the browser. Relative,//host/…,https:,data:andblob:all work, and the file can be PEM, a DER.cer/.crt, or a.p7b. Cross-origin URLs need CORS.TRUST_SOURCE_FAILEDwarning and comes out untrusted. The next verification tries again.file.trustandfile.trustSrc.My custom HTML elements also support maintained SVG backend that builds upon what PDF.js abandoned a while ago. Testing it every month against issues from PDF.js and PDFium! It also supports PDFium and does all the rendering off the main thread!
CetinSert commentedon Oct 1, 2026
Now with more examples:

and before someone starts scaremongering with "oh it's all in the frontend, we can't trust this" nonsense, the platform where I am building my custom HTML elements does have adjacent service/edge workers so signature verifications can be offloaded to the edge with zero user access. As for any unasked for concerns of people tampering with the pages in the frontend, obfuscator.io × closed shadow roots × MutationObserver and I am done before you can even open your mouth to complain!
Sorry, not sorry! Security guys act all snobby and annoyingly look down on people and I can't just shut up and take it anymore! Just because you have a browser (Firefox), does not mean the open web cannot be secured! I can even do open-source code delivered with obfuscation with proofs that what you get obfuscated for tamper-proofing IS exactly the open-source code byte for byte.