Repository navigation
Use the global fetch for OCSP requests - #479
Open
vishalhabib99 wants to merge 1 commit into
Open
vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit into
Conversation
checkOCSPStatus relied on two node-fetch v2-only APIs: the timeout option and response.buffer(). On runtimes where node-fetch resolves to a polyfill over the platform fetch (Cloudflare Workers with nodejs_compat), the OCSP request fails before it is sent, so online checks always return RETRYABLE_VERIFICATION_FAILURE. Use the global fetch with AbortSignal.timeout(30000) and read the body with arrayBuffer(). Behavior on Node is unchanged; the API client still uses node-fetch. Fixes apple#476
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #476 (blocker 2: the OCSP request).
checkOCSPStatusused two node-fetch v2-only APIs: thetimeoutoption andresponse.buffer(). When node-fetch resolves to a polyfill over the platformfetch, as it does in Cloudflare Workers withnodejs_compat, the OCSP request fails before it is sent, and online checks always returnRETRYABLE_VERIFICATION_FAILURE.This PR switches only the OCSP request to the global
fetch(Node 18+; CI runs 22, 24 and 26):signal: AbortSignal.timeout(30000)instead oftimeout: 30000Buffer.from(await response.arrayBuffer())instead ofresponse.buffer()HeadersAppStoreServerAPIClientstill uses node-fetch. ItsmakeFetchRequestis protected and returns a node-fetchResponse, so changing it would affect subclasses. I left it alone.Reproduction
I used a minimal Worker on wrangler 4.149.0 (workerd), with
compatibility_date = "2026-10-01"andnodejs_compat. It callsverifyCertificateChainwithenableOnlineChecks = trueon the real Apple chain and date fromshould validate a real chain with OCSP. As #476 suggests, the library is loaded with a dynamicimport()to get past the jsrsasign blocker. I ran it with--local-upstream foo.combecause Apple's responder returns 403 toCF-Worker: example.com.main:FAIL status=2 cause=(0 , node_fetch_1.default) is not a functionPASS(3 of 3 runs)Tests
jws_verification.test.tsnow mocks the globalfetchwith a standardResponse, which has nobuffer(). The delegated-responder test also checks that the request is a POST with the OCSP content type and anAbortSignal.yarn buildandnpx jestpass on Node 24: 17 suites, 456 tests, including the liveshould validate a real chain with OCSP.Note on #455 / #456
#456 fixes the timeout handling for #455 and edits the same lines. With this change the abort signal also covers reading the body, so a stalled body is aborted and the socket is closed. I didn't change how a body-read timeout is classified, which is what #456 handles. Whichever of the two merges first, I'm happy to rebase this one on top.