Skip to content

feat: server-side OCSP revocation checking - #25

Open
andyparsons wants to merge 4 commits into
mainfrom
ocsp-checking
Open

feat: server-side OCSP revocation checking#25
andyparsons wants to merge 4 commits into
mainfrom
ocsp-checking

Conversation

@andyparsons

Copy link
Copy Markdown
Collaborator

Summary

  • When the C2PA SDK reports signingCredential.ocsp.inaccessible (OCSP responders are typically HTTP, blocked by browsers as mixed content from HTTPS pages), the tool now automatically performs a server-side revocation check via a Netlify Function proxy
  • Client-side cert extraction parses the file's JUMBF/COSE bytes directly — only DER-encoded certificate bytes reach the server, never file content
  • Results are cached in-process with a configurable TTL (OCSP_CACHE_TTL_SECONDS: 1h production, 5m deploy preview)
  • Also fixes a Windows Chrome bug where HEIC/HEIF files always failed with "type is unsupported" (Windows has no native HEIC MIME type detection without an optional codec pack)

How the OCSP flow works

  1. After the SDK flags OCSP as inaccessible, ocspExtract.ts walks the file's JUMBF boxes to find the c2pa.signature bidb box
  2. CBOR-decodes the COSE_Sign1 envelope with cborg and pulls the x5chain (key 33) from the protected header
  3. Parses the leaf cert's AIA extension (@peculiar/x509) to find the OCSP responder URL
  4. POSTs { responderUrl, certDerB64, issuerDerB64 } to /.netlify/functions/ocsp-proxy
  5. The function builds a SHA-1 OCSP request DER, queries the responder, parses the response, and caches the result
  6. The UI reactively updates in the Signature Info section: ✅ "Not revoked (server-side check)", ❌ "Certificate revoked", or the original warning while the check is in flight

HEIC/HEIF Windows fix

Windows Chrome cannot identify HEIC/HEIF MIME types unless the optional HEIF Image Extensions codec pack is installed from the Microsoft Store. Without it, file.type arrives as '', resolveMimeType had no extension fallback for .heic/.heif, and the SDK received an empty format string. Added heic, heif, avci, and avcs to EXTENSION_MIME_MAP. No install required on Windows after this fix; thumbnails still show a placeholder since the browser can't render HEIC pixel data without the codec.

Test plan

  • Drop a file signed with a cert whose OCSP URL is http:// — report should update from "checking via server…" to "Not revoked (server-side check)" once the proxy responds
  • Verify files without ocsp.inaccessible status are unaffected
  • Confirm graceful fallback when the Netlify Function is unavailable (dev server without netlify dev) — should silently stay on "OCSP server inaccessible — checking via server…"
  • Drop a .heic file on Windows Chrome — should process without error and show a placeholder thumbnail
  • Verify .heic behaviour unchanged on Mac

🤖 Generated with Claude Code

andyparsons and others added 3 commits May 26, 2026 08:45
When the C2PA SDK reports signingCredential.ocsp.inaccessible (OCSP
unreachable from the browser due to mixed content or CORS), the client
now automatically extracts the signing certificate chain from the
file's JUMBF/COSE signature and forwards it to a Netlify Function
proxy that queries the OCSP responder server-side.

- ocspExtract.ts: client-side JUMBF walker + COSE CBOR unpacker that
  extracts the x5chain cert chain and OCSP responder URL from the file
- netlify/functions/ocsp-proxy.ts: in-process-cached Netlify Function
  that builds an OCSP request DER, queries the responder, and parses
  the revocation status
- Cache TTL configurable via OCSP_CACHE_TTL_SECONDS env var (1h prod,
  5m deploy-preview); cache resets on function cold start
- ReportViewer shows "Not revoked (server-side check)" / "Revoked" /
  "checking via server…" in place of the static inaccessible warning
- Requires cborg for client-side CBOR decoding of COSE protected header

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a dedicated "OCSP Revocation Checking" section explaining why
browser-side OCSP checks fail (mixed content / CORS), how the
client-side cert extraction and Netlify Function proxy work, the
cache TTL configuration, and how to test locally with netlify dev.

Also update: Features list, Project Structure, How It Works,
Privacy & Security, and Dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Windows does not natively recognise HEIC/HEIF file types unless the
optional HEIF Image Extensions codec pack is installed from the
Microsoft Store. Without it, Chrome cannot identify the MIME type and
sets file.type to '' for .heic/.heif drops.

The extension fallback map previously had no entry for these
extensions, so resolveMimeType returned '' and the C2PA SDK threw
"Failed to read C2PA data: type is unsupported".

Add heic, heif, avci, and avcs to EXTENSION_MIME_MAP so the extension
is used as a reliable fallback when the browser cannot detect the type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

Deploy Preview for c2pa-conformulator ready!

Name Link
🔨 Latest commit cd0d0b5
🔍 Latest deploy log https://app.netlify.com/projects/c2pa-conformulator/deploys/6a1da1c760f12d0007174bb5
😎 Deploy Preview https://deploy-preview-25--c2pa-conformulator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Logs at each decision point: whether a check is needed, cert extraction
outcome, responder URL, proxy request, and final result/error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant