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
{{ message }}
Repository navigation
Cloudflare Workers (nodejs_compat): SignedDataVerifier passes with online checks; two non-crypto blockers remain #476
In #255 you asked to be told if a runtime such as Cloudflare Workers now has the crypto needed to verify signed data. We tested it, and it does. Only two small issues block it, and neither involves the crypto.
What we measured
2026-10-23, @apple/app-store-server-library 3.1.0, wrangler 4.149.0 (workerd 1.20261006.1), compatibility_date = "2026-10-01", compatibility_flags = ["nodejs_compat"]. Node v24 was the control.
Check
Cloudflare edge (NRT), 3 runs
Node v24
Real Apple chain with OCSP (enableOnlineChecks = true). We used the certificates and date from this repo's test should validate a real chain with OCSP
passes (116–146 ms)
passes (199–216 ms)
verifyAndDecodeTransaction on a JWS signed by a test chain (online checks off)
passes
passes
Same JWS with its payload tampered
rejected
rejected
The library's use of node:crypto (X509Certificate, signature verification, hashing) worked as-is under nodejs_compat.
What blocked it
jsrsasign generates random values at import time. When the module loads, it calls crypto.getRandomValues. Workers do not allow random generation in global scope (Disallowed operation called within global scope), so a static import stops the Worker from starting. Our workaround is a dynamic import() inside the request handler.
The OCSP request relies on node-fetch v2-only APIs: fetch(url, { timeout }) and response.buffer(). On Workers, the bundler replaces node-fetch with a polyfill that forwards to the platform fetch. That polyfill has neither API, and the call fails with (0 , node_fetch_1.default) is not a function. Our workaround is to alias node-fetch to a wrapper of about 30 lines.
Suggestion
For (2), the OCSP request could use the global fetch (Node 18+) with signal: AbortSignal.timeout(30000), and read the body with Buffer.from(await response.arrayBuffer()). Because the abort signal also covers reading the body, I think this would also fix #455.
For (1), #472 is one approach (it replaces jsrsasign). A smaller change would be to load jsrsasign lazily in the verification path, since those methods are already async.
Note for local testing
wrangler dev --local sends CF-Worker: example.com on outgoing requests, and Apple's OCSP responder answers 403 to that value. Requests with no header, or with other values (foo.com, workers.dev), get 200. A deployed Worker gets 200 too. This only matters when testing OCSP locally. --local-upstream <your-domain> avoids it.
Some context on PR #472: I would not recommend merging it as-is for now. It replaces jsrsasign more broadly, but in my Cloudflare Workers tests it did not improve performance; the verification path became somewhat slower. I also have not rebased it or resolved conflicts with changes merged since then, because I do not currently consider that approach the preferred direction.
Instead, I opened PR #480 as a smaller interim fix. It lazily loads jsrsasign only when verification is used, avoiding RNG initialization during Worker module loading while keeping the existing verification implementation unchanged.
For the longer term, I’m considering a small Zig/WASM implementation of only the ASN.1/OCSP subset used by this library. That idea is still exploratory, but it may offer a better path for reducing CPU usage without rewriting the whole library.
Activity
Preeternal commentedon Nov 14, 2026
Some context on PR #472: I would not recommend merging it as-is for now. It replaces jsrsasign more broadly, but in my Cloudflare Workers tests it did not improve performance; the verification path became somewhat slower. I also have not rebased it or resolved conflicts with changes merged since then, because I do not currently consider that approach the preferred direction.
Instead, I opened PR #480 as a smaller interim fix. It lazily loads jsrsasign only when verification is used, avoiding RNG initialization during Worker module loading while keeping the existing verification implementation unchanged.
For the longer term, I’m considering a small Zig/WASM implementation of only the ASN.1/OCSP subset used by this library. That idea is still exploratory, but it may offer a better path for reducing CPU usage without rewriting the whole library.