Skip to content

Digital Signature and Certificate verification#21247

Open
beurdouche wants to merge 6 commits into
mozilla:masterfrom
beurdouche:master
Open

Digital Signature and Certificate verification#21247
beurdouche wants to merge 6 commits into
mozilla:masterfrom
beurdouche:master

Conversation

@beurdouche
Copy link
Copy Markdown
Member

No description provided.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 9, 2026

Codecov Report

❌ Patch coverage is 5.02513% with 378 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.89%. Comparing base (e86e9d9) to head (fe81d07).
⚠️ Report is 85 commits behind head on master.

Files with missing lines Patch % Lines
web/signature_properties_manager.js 1.01% 292 Missing ⚠️
src/core/document.js 1.33% 74 Missing ⚠️
web/app.js 57.14% 9 Missing ⚠️
src/display/api.js 50.00% 2 Missing ⚠️
src/core/worker.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #21247       +/-   ##
===========================================
+ Coverage   54.57%   65.89%   +11.32%     
===========================================
  Files         216      250       +34     
  Lines       58860    64603     +5743     
===========================================
+ Hits        32120    42572    +10452     
+ Misses      26740    22031     -4709     
Flag Coverage Δ
fonttest 8.67% <ø> (?)
integrationtest 65.84% <5.02%> (?)
unittestcli ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread l10n/en-US/viewer.ftl Outdated
Comment thread l10n/en-US/viewer.ftl
Comment thread l10n/en-US/viewer.ftl Outdated
Comment thread l10n/en-US/viewer.ftl
Comment thread web/app.js Outdated
Comment thread web/app.js Outdated
Comment thread web/app.js Outdated
Comment thread web/app.js Outdated
Comment thread web/app.js Outdated
Comment thread web/app.js
@marco-c
Copy link
Copy Markdown
Contributor

marco-c commented May 11, 2026

Was UX/Content involved with this?

How is a user supposed to differentiate these signatures from the signatures PDF.js already supports? I find the use of the same terminology very confusing.

They were consulted and they didn't agree with this approach (the main reason being what you said here), so it's not going to be enabled in Firefox but only in Enterprise Firefox.

Comment thread src/core/document.js Outdated
Comment thread src/core/document.js
const refKey = fieldRef instanceof Ref ? fieldRef.toString() : "inline";
const id = `${refKey}:${a}-${b}-${c}-${d}`;

const fileLength = stream.end || 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's correct in general.
@Snuffleupagus could it be wrong if the pdf is from a ranged request ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that PDFDocument is initialized either with a Stream or a ChunkedStream, where the latter extends the former, this part ought to be fine.

However, looking at this now I wonder why stream.end is being used and if that's actually intended?
What is fileLength actually supposed to represent here, is it either:

  • The length of the entire raw file passed to PDF.js?
    If this is the answer, then I suppose that stream.end is appropriate (although quite unexpected, see below).

  • The length of the actual PDF-data contained within the raw file?
    That can be shorter if there's "garbage" in the file before the %PDF- header, which marks the start of the actual PDF-data (in which case stream.moveStart() will update the start-position of the stream).

    Given that all "normal" data in a PDF document is always referenced from the %PDF- header position, naively I'd thus expect that you actually want stream.length here (which is fine as long as you're only dealing with Stream instances).

Comment thread web/firefoxcom.js Outdated
Comment thread web/signature_properties_manager.js Outdated
Comment thread web/signature_properties_manager.js Outdated
banner.className = `sigBanner ${severity}`;
banner.setAttribute(
"data-l10n-id",
`pdfjs-signature-properties-banner-${worst}`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid generating l10n ids, similarly to what we did in #21263 ?

Comment thread web/signature_properties_manager.js
Comment thread web/signature_properties_manager.js Outdated
Comment thread web/signature_properties_manager.js Outdated
for (const sig of this.#signatures) {
if (sig.parentId) {
if (!byParent.has(sig.parentId)) {
byParent.set(sig.parentId, []);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: getOrInsertComputed

Comment thread web/signature_properties_manager.js Outdated
#render() {
const list = this.#appConfig.signaturePropertiesList;
const banner = this.#appConfig.signaturePropertiesBanner;
list.replaceChildren();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably use a documentFragment and use list.replaceChildren(fragment).

this.#updateButtonState();
}

#updateButtonState() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function looks a bit similar to bannerStateForResults, maybe you could factorize a bit.

Comment thread test/pdfs/sig_corpus/generate.py Outdated
from pathlib import Path

CORPUS_DIR = Path(__file__).resolve().parent
FIREFOX_DIR = Path("/opt/mozilla/firefox")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bad idea to have this hardcoded path.

Comment thread test/pdfs/sig_corpus/README.md Outdated
`security/manager/tools/pycms.py` and reuses its vendored Python
modules under `third_party/python/{ecdsa,rsa,pyasn1,pyasn1_modules,six}`.
2. The Firefox build at
`/opt/mozilla/firefox/obj-aarch64-apple-darwin25.4.0/dist/Nightly.app`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have something more generic ?

Comment thread test/pdfs/sig_corpus/README.md Outdated
Launch the dev Firefox:

```sh
/opt/mozilla/firefox/obj-aarch64-apple-darwin25.4.0/dist/Nightly.app/Contents/MacOS/firefox \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we something more generic ?

Comment thread web/signature_properties.css
Comment thread web/signature_properties.css
Comment thread web/signature_properties.css Outdated
&.status--revoked::before,
&.cert--trusted::before {
background-color: transparent;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='8' cy='8' r='7' fill='white' stroke='%23969696' stroke-width='1'/><path fill='none' stroke='%23969696' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M5 8.4l2.4 2.4L11.6 6'/></svg>");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably live in svg file and again take care about the colors depending on the theme.

Comment thread web/signature_properties.css Outdated
* class is set in #render. */
.sigCard--top-allfine > .sigCard__row.status--verified::before,
.sigCard--top-allfine > .sigCard__row.cert--trusted::before {
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='8' cy='8' r='7' fill='%231d8e3d'/><path fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4.5 8.4l2.4 2.4L11.6 6'/></svg>");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Comment thread web/signature_properties.css Outdated
background: var(--field-bg-color, white);
}

.sigCard__signer {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably have class "signer" and and use nested css instead.
The same comment applied for other similar pattern (foo__bar).

Comment thread web/signature_properties.css Outdated
}
}

@keyframes signaturePropertiesDots {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm wrong, but I've the feeling we can do better here...

Comment thread web/signature_properties_manager.js
Comment thread web/firefoxcom.js
Comment thread web/signature_properties_manager.js Outdated
beurdouche and others added 3 commits May 13, 2026 20:44
Switch the panel row icons and the toolbar button state badge from
`background-image:` (full-colour SVG, never themes) to `mask-image:` +
`background-color:`. The colour comes from new `--sig-icon-*` tint
vars that resolve via `light-dark()` in normal mode and collapse to
`CanvasText` in `forced-colors: active`.

- Rewrite `toolbarButton-signaturePropertiesVerified/Warn/Error.svg`
  as mono filled-disc silhouettes with a transparent glyph cutout
  (via `<mask>`).
- New `signature-properties-row-check.svg` — outline check used by the
  default/fine row states (supersedes
  `signature-properties-status-check.svg`).
- Drop `--signatureProperties-statusCheck-icon`, add
  `--signatureProperties-rowCheck-icon`.
- Add `--sig-icon-{default,warn,error,verified}` tint vars with
  forced-colors fallbacks; toolbar + row rules both reference them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement digital signature validation

7 participants