feat: trust internal CAs in browser monitors#1149
Draft
shahzad31 wants to merge 2 commits into
Draft
Conversation
Browser journeys run on headless Chromium, which trusts its own NSS store rather than the system CA store on Linux. As a result, sites served by an internal/private CA fail with ERR_CERT_AUTHORITY_INVALID and the only escape hatch was `ignoreHTTPSErrors`, which disables TLS validation for every endpoint. Add a `certificateAuthorities` option (Synthetics config and the `--certificate-authorities` CLI flag, accepting inline PEM or file paths). The agent computes the SHA-256 SPKI fingerprint of each CA and launches Chromium with `--ignore-certificate-errors-spki-list`, so only certificates issued by the provided CAs are trusted while normal validation still applies to all other endpoints. Inline PEM keeps this usable on Elastic-managed locations without rebuilding the agent image. Co-authored-by: Cursor <cursoragent@cursor.com>
4 tasks
Demonstrates the new `certificateAuthorities` option for trusting an internal CA from a browser monitor, with end-to-end local testing instructions (throwaway CA + HTTPS server). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Browser journeys run on headless Chromium, which on Linux trusts its own NSS store rather than the system CA store. Sites served by an internal/private CA therefore fail with
ERR_CERT_AUTHORITY_INVALID, and the only workaround was either rebuilding theelastic-agent-completeimage to inject the CA into the NSS DB, or usingignoreHTTPSErrors(which disables TLS validation for every endpoint).This PR adds first-class support for trusting internal CAs in browser monitors:
certificateAuthoritiesoption, available via the Synthetics config and the--certificate-authoritiesCLI flag. Each entry can be inline PEM content or a path to a PEM file.SubjectPublicKeyInfoand launches Chromium with--ignore-certificate-errors-spki-list=<fingerprints>. Only certificates issued by the provided CAs are trusted; normal validation still applies to all other endpoints (unlikeignoreHTTPSErrors).Closes #717
Closes #170
Why SPKI pinning instead of
ignoreHTTPSErrors--ignore-certificate-errors-spki-listscopes the trust to the user's own CA public key, so a real MITM presenting a different certificate still fails the monitor.ignoreHTTPSErrorsblanket-disables validation, which most enterprises can't accept.Usage
Config (
synthetics.config.ts) — each entry is a path to a PEM file, inline PEM, aBuffer, or an array of any of these:CLI (variadic — pass more than one):
npx @elastic/synthetics . --certificate-authorities ./certs/internal-ca.crtA runnable example (config + journey + README) lives in
examples/internal-ca.Try it locally
No internal infra needed — spin up a throwaway CA + HTTPS server and watch the journey flip from failing to passing:
Confirm the flag actually reached Chromium:
Test plan
__tests__/core/certs.test.ts)__tests__/options.test.ts--certificate-authoritiesand still fails without it (__tests__/cli.test.ts)tsc,eslint,prettier --check, full unit suite greenNotes
--ignore-certificate-errors-spki-listswitch ignores all certificate errors (including expiry/hostname) for the pinned key, by design.chromium.launchpath; the remotewsEndpoint/connectpath is unaffected.Made with Cursor