Skip to content

SDK-6180 Support proxyCaCertificate for SSL-inspecting proxies#1116

Open
AakashHotchandani wants to merge 3 commits into
masterfrom
SDK-6180-proxyca
Open

SDK-6180 Support proxyCaCertificate for SSL-inspecting proxies#1116
AakashHotchandani wants to merge 3 commits into
masterfrom
SDK-6180-proxyca

Conversation

@AakashHotchandani
Copy link
Copy Markdown
Collaborator

@AakashHotchandani AakashHotchandani commented Jun 2, 2026

What is this about?

Adds proxyCaCertificate support so the Cypress CLI works behind SSL-inspecting corporate proxies (Zscaler/Netskope/Forcepoint).

  • New proxyCaCertificate (path to a PEM CA), read from connection_settings.proxyCaCertificate (or top-level) in browserstack.json; env BROWSERSTACK_EXTRA_CA_CERTS overrides.
  • Merged with the system trust store (never replaces).
  • Missing/invalid path logs a WARN and falls back to defaults — never breaks the run.

How

The CLI makes outbound HTTPS via axios across ~10 files (some via HttpsProxyAgent, some direct), so rather than patch each:

  • bin/helpers/caCertHelper.js patches tls.createSecureContext once and addCACerts the customer cert — honored by every axios call and the proxy tunnel, merged with default roots. Also sets NODE_EXTRA_CA_CERTS.
  • Hooked in validateBstackJson (runs first in every command, before any axios call).

Verification (mitmproxy SSL-inspecting proxy)

Drove the real caCertHelper + axios through mitmproxy: without the cert → UNABLE_TO_VERIFY_LEAF_SIGNATURE; with it → success (HTTP 404 through the proxy). Cert-gated: without the cert the CLI still rejects the MITM cert; merge keeps public roots.

Related Jira

🤖 Generated with Claude Code

AakashHotchandani and others added 3 commits June 2, 2026 16:33
Trust a customer-provided CA bundle for all outbound HTTPS (axios) for
customers behind SSL-inspecting corporate proxies (Zscaler/Netskope).

- New bin/helpers/caCertHelper.js: resolves the cert (env
  BROWSERSTACK_EXTRA_CA_CERTS > browserstack.json connection_settings.
  proxyCaCertificate or top-level), patches tls.createSecureContext to
  addCACert it (MERGED with system roots; covers every axios call and the
  HttpsProxyAgent tunnel in one hook), and sets NODE_EXTRA_CA_CERTS. Never throws.
- Hooked in validateBstackJson (runs first in every command, before any axios call).

Verified through mitmproxy: with the cert, axios requests succeed through the
proxy; without it the CLI still rejects the MITM cert (cert-gated).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ny extension)

caCertHelper read the cert as utf8 and addCACert'd it once: a DER (binary) cert
(e.g. a Windows .cer export) was corrupted/dropped, and a multi-cert PEM bundle had
only its first cert trusted. Added loadCaCertsAsPem (content-sniffs PEM single/bundle
vs DER, converting DER->PEM via base64 wrap) and addCACert each cert. NODE_EXTRA_CA_CERTS
now points at a PEM file (the customer's path when already PEM, else a PEM-converted
temp) since Node can't load a raw DER through that var.

So .pem/.crt/.cer/.der all work regardless of extension. Verified addCACert accepts
both PEM and DER inputs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… 0600 + O_EXCL)

Security review flagged the predictable temp path used for NODE_EXTRA_CA_CERTS when
converting a DER cert. Now write into a fresh owner-only dir (fs.mkdtempSync) and open
the file with O_EXCL|O_NOFOLLOW at mode 0600, preventing a local pre-plant/symlink-race
on the file the process trusts as a CA.

Co-Authored-By: Claude Opus 4.8 <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