Skip to Content
Intercept vendor calls

Guides

Intercept vendor calls

rystic run --intercept puts a simulator behind a local HTTPS gateway. rystic exec runs your command with that gateway as its proxy. Calls to api.stripe.com, slack.com, s3.amazonaws.com and the other simulated hosts land on your simulators, and your code stays as it is.

To point a client at http://localhost:<port> instead, see the base-URL change on each simulator’s page, for example Stripe. That route needs no gateway.

Quick start

rystic run stripe-twin --intercept -d --name stripe --port 0
# -> stripe-twin ... (model ...) → http://localhost:... [native stripe] · intercept
# -> next: rystic docs stripe-twin   # how to call it: auth, endpoints, the live routes
# -> next: rystic exec --project default -- <command>   # its calls to ... land here
# -> stop: rystic stop stripe

rystic exec -- curl -s https://api.stripe.com/v1/charges -u sk_test_anything: \
  -d amount=2000 -d currency=usd -d source=tok_visa
# -> {..."id":"ch_000000000000000000000001",..."status":"succeeded",...}

Two more simulators, and a Python app that names neither:

rystic run slack-twin --intercept -d --name slack --port 0 --scenario design_studio
rystic run s3-twin    --intercept -d --name s3    --port 0
rystic exec -- python3 app.py
# -> True 1
# app.py: boto3 and slack_sdk with their default hosts
import boto3
from slack_sdk import WebClient

s3 = boto3.client("s3", region_name="us-east-1",
                  aws_access_key_id="AKIAEXAMPLE", aws_secret_access_key="secret")
s3.create_bucket(Bucket="statements")
s3.put_object(Bucket="statements", Key="2026/10/acme.pdf", Body=b"%PDF-1.7")

slack = WebClient(token="xoxb-anything")
r = slack.chat_postMessage(channel="CWDC0000004", text="statement for acme filed")
print(r["ok"], s3.list_objects_v2(Bucket="statements")["KeyCount"])

On a Mac, exec prints one more line on stderr until the CA is in your keychain. It matters only for Go tools; see Go tools on macOS.

How the pieces fit

  1. rystic run <product> --intercept boots the simulator for the gateway. The URLs it hands back keep the vendor’s hosts, such as PayPal’s links, Lob’s next_url and GitHub’s html_url, instead of naming localhost. A client that follows one comes back through the gateway.
  2. The gateway: one per project, listening on 127.0.0.1 only. For each host that an --intercept simulator in the project claims, it terminates TLS with a certificate from the Rystic CA and forwards the request to that simulator, Host unchanged. It re-reads the simulators as requests arrive, so it picks up a simulator started or stopped later without a restart.
  3. rystic exec -- <cmd> starts the project’s gateway if none runs, sets the environment, then becomes <cmd>. The exit code and signals are the command’s own.
  4. eval "$(rystic env)" puts the same exports in your shell, so every later command in it is routed.
  5. rystic gateway runs the gateway in the foreground and logs to the terminal. --port fixes its port, and exec and env use it while it runs. Ctrl-C ends it.

Each of these commands takes --project, which defaults to default. Each project gets its own gateway, so two copies of one simulator can run side by side under different projects.

The detached gateway

  1. Starts on the first rystic exec or rystic env in a project with no gateway running, or on a rystic up whose stack file has an intercept: true service.
  2. Listens on a free port on 127.0.0.1. rystic env prints it.
  3. Is recorded in ~/.rystic/run/gateway/<project>.json.
  4. Logs to ~/.rystic/run/gateway/<project>.log, one line per connection and per request.
  5. Stops on rystic gateway --stop or rystic down. rystic stop leaves it running.
… rystic gateway for project default on http://127.0.0.1:61203 (without --strict) — …
… CONNECT api.stripe.com:443 → stripe-twin/stripe (http://localhost:52114)
… POST api.stripe.com/v1/charges → 200 (stripe-twin/stripe)
… tunnel example.com:443
rystic gateway --stop
# -> stopped the gateway for project default (pid ...)

Stack files

In a stack file, intercept: true on a service is rystic run --intercept. rystic up starts those simulators under the stack’s project, then starts that project’s gateway:

# rystic.yaml
version: 1
project: shop
gateway: {strict: true}
services:
  payments: {product: stripe-twin, port: 0, intercept: true}
  pulls: {product: github-pulls-twin, port: 0, intercept: true, scenario: github-pulls_open_queue}
rystic up -d
# -> stripe-twin ... → http://localhost:... [native payments] · intercept
# -> github-pulls-twin ... → http://localhost:... [native pulls] · intercept
# -> gateway: http://127.0.0.1:... (--strict with no --allow) — next: rystic exec --project shop -- <command>   # routes the intercept services' hosts
rystic exec --project shop -- curl -s https://api.stripe.com/v1/customers -u sk_test_anything:
# -> {..."object":"list"...}
rystic exec --project shop -- curl -sS https://example.com/    # strict, from the stack file
# -> curl: (56) CONNECT tunnel failed, response 403
  1. The top-level gateway key takes strict and allow, the same policy as --strict and --allow. allow needs strict: true, and a file with gateway but no intercept: true service exits 2.
  2. rystic exec and rystic env without --strict or --allow keep the policy the project’s gateway last ran with, so rystic exec --project shop is strict here. The policy holds even after the gateway stops unexpectedly, in a crash, a signal or a reboot. Only rystic gateway --stop or rystic down clears it, and the next gateway starts without --strict.
  3. rystic down stops the gateway with the simulators.
  4. A service already running with a different intercept setting stops up (exit 9), naming the service. Stop it, then run up again.
rystic gateway --stop --project shop
# -> stopped the gateway for project shop (pid ...)
rystic exec --project shop -- curl -sS -o /dev/null -w '%{http_code}\n' https://example.com/    # a new gateway, without --strict
# -> 200
rystic down
# -> stopped pulls
# -> stopped payments
# -> stopped the gateway for project shop (pid ...)

The environment

rystic env
export HTTPS_PROXY=http://127.0.0.1:61203
export https_proxy=http://127.0.0.1:61203
export HTTP_PROXY=http://127.0.0.1:61203
export http_proxy=http://127.0.0.1:61203
export NO_PROXY=localhost,127.0.0.1,::1
export no_proxy=localhost,127.0.0.1,::1
export NODE_USE_ENV_PROXY=1
export SSL_CERT_FILE=/Users/you/.rystic/ca/bundle.pem
export REQUESTS_CA_BUNDLE=/Users/you/.rystic/ca/bundle.pem
export CURL_CA_BUNDLE=/Users/you/.rystic/ca/bundle.pem
export GIT_SSL_CAINFO=/Users/you/.rystic/ca/bundle.pem
export AWS_CA_BUNDLE=/Users/you/.rystic/ca/bundle.pem
export HTTPLIB2_CA_CERTS=/Users/you/.rystic/ca/bundle.pem
export NODE_EXTRA_CA_CERTS=/Users/you/.rystic/ca/ca.pem
export GODEBUG=x509sslcertoverrideplatform=1
  1. bundle.pem holds your system’s roots plus the Rystic gateway CA, so hosts the gateway passes through still verify. ca.pem is the CA alone.
  2. NO_PROXY keeps calls to a simulator’s own localhost port off the gateway.
  3. GODEBUG is appended to any value you already set.
  4. rystic env --json prints the same under data.env, with the gateway’s URL, pid, CA, bundle and log paths.
  5. The first exec or env creates the CA under ~/.rystic/ca/, valid for five years. Its critical name constraints let it sign only for the simulated hosts, never for an IP address.

What each runtime reads

clienttrusts the CA through
curlCURL_CA_BUNDLE, else SSL_CERT_FILE
gitGIT_SSL_CAINFO
Python urllib and ssl, and libraries built on them such as slack_sdkSSL_CERT_FILE
Python requestsREQUESTS_CA_BUNDLE, else CURL_CA_BUNDLE
boto3, AWS CLIAWS_CA_BUNDLE
Python httplib2, and google-api-python-client on itHTTPLIB2_CA_CERTS
Node fetch, the global https agent and SDKs that use them, such as @slack/web-apiNODE_EXTRA_CA_CERTS. The proxy is used only when Node reads NODE_USE_ENV_PROXY (Node 24, or 22.21 and later); an older Node connects directly
Ruby Net::HTTPSSL_CERT_FILE
Goon macOS before Go 1.27, the login keychain only: rystic trust. Elsewhere SSL_CERT_FILE, which GODEBUG makes Go 1.27 read on macOS

Clients that need one more step

clientunchanged, it…make it route
stripe for Pythonverifies TLS against the CA file it ships and reads no CA variable: APIConnectionError: Could not verify Stripe's SSL certificatestripe.ca_bundle_path = os.environ["SSL_CERT_FILE"], or in Compose, no change: SDKs that ship their own CA file
stripe for Ruby and stripe/stripe-phpverify TLS against the CA file they shipStripe.ca_bundle_path = ENV["SSL_CERT_FILE"], \Stripe\Stripe::setCABundlePath(getenv('SSL_CERT_FILE')), or in Compose, no change
paypal-sdk-rest for Rubyverifies TLS against the CA file it shipsssl_options: { ca_file: ENV["SSL_CERT_FILE"] } in PayPal::SDK.configure, or in Compose, no change
stripe for Nodebrings its own agent and reaches Stripe directly: StripeAuthenticationError: Invalid API Key providednew Stripe(key, { httpAgent: https.globalAgent })
@paypal/paypal-server-sdk with an older axios, which the library’s own range still admitssends HTTPS requests in a form the gateway refuses with 400npm install axios@latest beside it
AWS SDK for JavaScript v3brings its own agent and reaches AWS directly: InvalidAccessKeyIdnew S3Client({ …, requestHandler: { httpsAgent: https.globalAgent } })
Java HttpClientignores the variables and connects directly-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=<gateway port> -Djavax.net.ssl.trustStore=<store>, with ca.pem imported into <store> by keytool -importcert
macOS /usr/bin/python3 (3.9, LibreSSL 2.8)rejects the CA: CERTIFICATE_VERIFY_FAILEDa Python built on OpenSSL, such as Homebrew’s
Go before 1.27 on macOS, Homebrew gh among themx509: certificate signed by unknown authorityrystic trust

Go tools on macOS: rystic trust

On macOS, Go before 1.27 checks certificates against the keychain only, so SSL_CERT_FILE doesn’t reach it. Until the CA is trusted, exec, env and doctor say so:

rystic: the gateway CA is not trusted in your login keychain, so Go tools built before Go 1.27 (Homebrew gh among them) refuse simulated hosts — `rystic trust` adds it (one password prompt)
rystic trust            # add ~/.rystic/ca/ca.pem to the login keychain as a trusted root; one password prompt
rystic trust --remove   # take this install's current and superseded gateway CAs out again
  1. The CA’s name constraints confine it to the simulated hosts, so trusting it vouches for no other site.
  2. When a newer rystic simulates more hosts, it replaces the CA and says so. Run rystic trust again.
  3. On Linux, SSL_CERT_FILE carries the CA and rystic trust changes nothing. Windows has its own step: On Windows.

On Windows

The installer covers macOS and Linux; a Windows build is on request. On it, intercept works as above, with three differences:

  1. rystic exec runs your command as a child process rather than replacing itself. It passes Ctrl-C on and exits with the command’s exit code.
  2. rystic env prints export lines, for a POSIX shell such as Git Bash. In PowerShell or cmd, set the variables rystic env --json lists under data.env.
  3. rystic trust changes nothing. Go tools built before Go 1.27 need ca.pem, the file under data.ca, imported into the Windows certificate store as a trusted root. Other clients read the variables.
rystic env --json | jq -r '.data.env | keys[]' | head -3
# -> AWS_CA_BUNDLE
# -> CURL_CA_BUNDLE
# -> GIT_SSL_CAINFO

From a container

The gateway listens on 127.0.0.1 only, so a container reaches it through the host. Name the gateway as the container’s proxy, and mount the CA for the client to trust. On Docker Desktop the host is host.docker.internal:

PROXY=$(rystic env --json | jq -r '.data.gateway | sub("127.0.0.1"; "host.docker.internal")')
CA=$(rystic env --json | jq -r .data.ca)
docker run --rm -e HTTPS_PROXY=$PROXY -v $CA:/rystic-ca.pem:ro curlimages/curl \
  -s --cacert /rystic-ca.pem https://api.stripe.com/v1/customers -u sk_test_anything:
# -> {..."object":"list"...}
  1. On Docker Engine for Linux, a container reaches the host’s 127.0.0.1 only with --network host. Run it that way and keep the gateway URL as rystic env prints it. Docker Desktop for Linux works as on a Mac.
  2. Set the CA variable your client reads (What each runtime reads) to a mounted file, since the host paths in rystic env don’t exist inside the container. A variable that replaces the trust store, such as SSL_CERT_FILE, takes bundle.pem (data.bundle), so hosts the gateway passes through still verify. NODE_EXTRA_CA_CERTS and curl --cacert take ca.pem (data.ca).
  3. The simulators run on the host, so the gateway reaches them as it always does.
  4. When the simulators run as containers too, run the gateway as one: In Docker Compose.

In Docker Compose

When your app and the simulators are all Compose services, the gateway is one more service on the same network. rystic compose up writes the stack file, exports it and starts your app with it in one command. This section is what it runs, step by step. Mark each simulator intercept: true in a stack file that pins each version, name your app’s service in gateway: {apps}, then export it:

# rystic.yaml
version: 1
project: shop
gateway: {strict: true, apps: [app]}
services:
  stripe: {product: stripe-twin, version: 0.0.36, intercept: true}
  github: {product: github-pulls-twin, version: 0.0.32, intercept: true, scenario: github-pulls_open_queue}
rystic export compose -o ./deploy
# -> wrote .env.example, docker-compose.yaml to ./deploy

The exported file runs each simulator with RYSTIC_PRESERVE_SERVICE_URLS=1 and adds a rystic-gateway service, a rystic-ca volume and an app service that holds only the wiring. Its default network has no route out. This export ran on a license; on an API key each simulator gets RYSTIC_TOKEN: ${RYSTIC_TOKEN} instead (Export to Compose):

# deploy/docker-compose.yaml, in part
networks:
  default:
    internal: true
  rystic-egress: {}
  rystic-intercept:
    internal: true
services:
  app:
    depends_on:
      github: {condition: service_healthy}
      rystic-gateway: {condition: service_healthy}
      stripe: {condition: service_healthy}
    environment:
      HTTPS_PROXY: http://rystic-gateway:3128
      HTTPLIB2_CA_CERTS: /rystic-ca/bundle.pem
      NODE_EXTRA_CA_CERTS: /rystic-ca/ca.pem
      NODE_USE_ENV_PROXY: "1"
      SSL_CERT_FILE: /rystic-ca/bundle.pem
    networks:
      default: {}
      rystic-intercept: {}
    volumes:
    - {type: volume, source: rystic-ca, target: /rystic-ca, read_only: true}
    - {type: volume, source: rystic-ca, target: /etc/ssl/certs/ca-certificates.crt, read_only: true, volume: {subpath: bundle.pem, nocopy: true}}
  rystic-gateway:
    command:
    - rystic
    - gateway
    - --listen
    - 0.0.0.0:3128
    - --listen-tls
    - :443
    - --ca-out
    - /work
    - --upstream
    - stripe-twin=http://stripe:8080
    - --upstream
    - github-pulls-twin=http://github:8080
    - --strict
    - --allow
    - stripe
    - --allow
    - github
    - --allow
    - app
    healthcheck:
      test: [CMD-SHELL, test -s /work/ca.pem]
    image: registry.rystic.ai/stripe-twin@sha256:…
    networks:
      default: {}
      rystic-egress: {}
      rystic-intercept:
        aliases:
        - api.github.com
        - api.notion.com
        - api.resend.com
        - api.stripe.com
        - github.com
        - …
    ports:
    - 127.0.0.1::3128
    volumes:
    - rystic-ca:/work
  stripe:
    environment:
      RYSTIC_LICENSE: ${RYSTIC_LICENSE}
      RYSTIC_PRESERVE_SERVICE_URLS: "1"
    networks:
      default: {}
      rystic-egress: {}
    volumes:
    - rystic-stripe-data:/var/lib/rystic/data
volumes:
  rystic-ca: {}
  rystic-github-data: {}
  rystic-stripe-data: {}

Your own Compose file brings the app’s image or build. Pass it first: Compose merges the exported app into the service of the same name, resolves paths from the first file’s folder and reads .env beside it (or pass --env-file deploy/.env):

# compose.yaml
services:
  app:
    build: .
docker compose -f compose.yaml -f deploy/docker-compose.yaml run --rm app \
  curl -s https://api.stripe.com/v1/customers -u sk_test_anything:
# -> {..."object":"list"...}
docker compose -f compose.yaml -f deploy/docker-compose.yaml run --rm app curl -sS https://example.com/
# -> curl: (56) CONNECT tunnel failed, response 403

curl --noproxy '*' stands in for a client that ignores HTTPS_PROXY. It reaches the simulator directly, and a host no simulator claims fails the handshake:

docker compose -f compose.yaml -f deploy/docker-compose.yaml run --rm app \
  curl -s --noproxy '*' https://api.stripe.com/v1/customers -u sk_test_anything:
# -> {"data":[],"has_more":false,"object":"list","url":"/v1/customers"}
docker compose -f compose.yaml -f deploy/docker-compose.yaml run --rm app \
  curl -sS --noproxy '*' --connect-to example.com:443:rystic-gateway:443 https://example.com/
# -> curl: (35) TLS connect error: error:0A000458:SSL routines::tlsv1 unrecognized name
docker compose -f compose.yaml -f deploy/docker-compose.yaml logs rystic-gateway
# -> ... direct TLS on [::]:443, routed by SNI, for api.github.com api.stripe.com ... github.com ...
# -> ... GET api.stripe.com/v1/customers → 200 (stripe-twin/stripe:8080)
# -> ... refused TLS for example.com: no simulator claims it, and a direct TLS connection names no destination to tunnel to

A proxied call logs a CONNECT line before its GET; a direct call logs the GET alone.

  1. The rystic-gateway service runs rystic gateway --upstream <product>=<url> once per simulator, on the image of the first intercept service in the stack file, which carries the CLI. The file’s header names that image. Each --upstream routes that simulator’s hosts to its service by name, for example stripe-twin=http://stripe:8080. That image must be a release whose CLI has --listen-tls; an older one exits at start.

  2. --listen 0.0.0.0:3128 accepts proxy clients from the Compose network. The export also publishes it on your machine’s 127.0.0.1, at the port docker compose port rystic-gateway 3128 prints: The network. Without --listen, the gateway listens on 127.0.0.1 only.

  3. --listen-tls :443 accepts direct TLS and routes it by the host the client names. The gateway’s aliases give it every exact host the simulators claim on the rystic-intercept network, and, unless egress is open, every other vendor host a Rystic simulator covers, which it refuses. So a client that ignores HTTPS_PROXY, such as stripe for Node or the AWS SDK for JavaScript v3, reaches the simulator with no change. A host the gateway doesn’t route fails the handshake with unrecognized_name.

  4. The gateway creates its CA in memory each time it starts, and writes only the public ca.pem and bundle.pem (its system roots plus the CA) to --ca-out, the rystic-ca volume. The private key never leaves the gateway. A restarted gateway has a new CA, so restart your app after it.

  5. The app overlay sets HTTPS_PROXY and every CA variable rystic exec sets (What each runtime reads). Set NO_PROXY in your own file, with localhost,127.0.0.1,::1, to reach your own HTTPS services directly. Without apps, the exported file’s header lists this wiring to add by hand.

  6. The overlay also mounts bundle.pem read-only over the system trust store of Debian, Ubuntu, Alpine, distroless and the RHEL family, so a client that reads only that store trusts the CA too. That mount needs Docker Engine 26 or later. Its nocopy: true stops Docker 28 and older from trying to copy the image’s own file into the volume, which fails.

  7. An alias is one exact name, so a subdomain the client builds, such as an S3 bucket in the host name, the AWS SDK’s default, misses the gateway until gateway: {hosts} names it: gateway: {apps: [app], hosts: [statements.s3.us-east-1.amazonaws.com]}. Until then it doesn’t resolve, or with gateway: {egress: open} reaches the real vendor. Each entry must sit under a host an intercept simulator claims, or the export refuses it (exit 2):

    # rystic.yaml with gateway: {apps: [app], hosts: [api.example.com]}
    rystic export compose -o ./deploy
    # -> rystic: gateway: hosts "api.example.com" is under no host that github-pulls-twin, stripe-twin claims, so the gateway would refuse it
    
  8. gateway: {strict: true} becomes --strict, and each allow host becomes --allow, as does each stack service and app by name, so a host client on the published proxy reaches them. A simulated host with no --upstream is always refused: slack.com is simulated by slack-twin, and this gateway has no --upstream for it — add --upstream slack-twin=<url>. Under --strict, so is a host no simulator claims, through the proxy. A direct call to a host with no alias doesn’t resolve, or with gateway: {egress: open} reaches the real host.

  9. Each simulator mounts rystic-<service>-data, and on an API key rystic-<service>-leases: Export to Compose.

To write the gateway service by hand instead, as in any Compose file with simulator images:

services:
  rystic-gateway:
    image: registry.rystic.ai/stripe-twin:latest
    command: [rystic, gateway, --listen, "0.0.0.0:3128", --listen-tls, ":443",
              --ca-out, /work, --strict,
              --upstream, "stripe-twin=http://stripe:8080",
              --upstream, "github-pulls-twin=http://github:8080"]
    networks:
      default: {}
      rystic-intercept:
        aliases: [api.stripe.com, api.github.com, github.com]
    volumes:
      - rystic-ca:/work
    healthcheck:
      test: [CMD-SHELL, test -s /work/ca.pem]
      interval: 2s
      retries: 30
  app:
    networks: [default, rystic-intercept]
networks:
  rystic-intercept:
    internal: true
volumes:
  rystic-ca:

Give each simulator service RYSTIC_PRESERVE_SERVICE_URLS: "1", so the URLs in its responses keep the vendor’s hosts. The volume sits over /work, which the image’s user can write. Keep the simulators off rystic-intercept, so their own calls to the vendor resolve by real DNS. List under aliases each host your app calls directly; the gateway’s log names every host it routes on its direct TLS on [::]:443 line. For the app’s environment and trust store mounts, export with gateway: {apps} once and copy its overlay, or follow the exported file’s header.

The network

The exported default network has internal: true, so it has no route out, and a call your app makes that skips the gateway fails. The gateway and the simulators also join rystic-egress, a network with a route out. The gateway forwards proxied calls to hosts no simulator claims, under strict and allow as above, and a simulator makes its own calls there, such as an API key’s lease checks.

The gateway’s vendor-host aliases sit on a third network, rystic-intercept, also internal. Only the gateway and your wired apps join it: the services gateway: {apps} names, or under rystic compose, every service with a build: key. The simulators stay off it, so a simulator’s own call to its vendor, such as Kalshi’s live feed, resolves by real DNS.

  1. With egress closed, a service that isn’t wired doesn’t resolve the vendor hosts; under gateway: {egress: open} it reaches the real vendor. List it in gateway: {apps}, or give it networks: [default, rystic-intercept] in your file and declare rystic-intercept: {internal: true} under networks.
  2. A wired app is on two networks, and Docker keeps no order between them, so a server that binds its own hostname listens on only one network. Bind 0.0.0.0. rystic compose sets HOSTNAME=0.0.0.0 on each wired app unless your files or app_env set it; the export’s header says to bind it.

The gateway publishes its proxy on your machine’s loopback. A client or browser there that uses it and trusts its CA reaches each simulator at the vendor host your app calls. It reaches each simulator and app by its name in the stack too:

docker compose -f compose.yaml -f deploy/docker-compose.yaml cp rystic-gateway:/work/ca.pem ./ca.pem
PROXY=$(docker compose -f compose.yaml -f deploy/docker-compose.yaml port rystic-gateway 3128)
curl -s -x http://$PROXY --cacert ca.pem https://api.stripe.com/v1/customers -u sk_test_x: | jq -r .object
# -> list
  1. Docker publishes no port of a service whose networks are all internal, so a port your own service publishes gets no response on your machine. rystic compose moves each such port onto the gateway (rystic gateway --forward <port>=<service>:<port>); the export can’t, since it doesn’t read your file. Otherwise reach the service through the proxy.
  2. gateway: {egress: open} keeps Compose’s own default network, with a route out. The proxy is still published.
  3. The Antithesis export has no route out either way, and egress: open there gets a warning.

SDKs that ship their own CA file

A few SDKs verify TLS against a CA file inside their own package and read none of the CA variables, so the overlay’s variables and trust store mounts don’t reach them. rystic compose up finds each such file in your app’s image and mounts bundle.pem read-only over it, with no flag:

simulatorSDKthe file, under the package’s folder
Stripestripe for Pythonsite-packages/stripe/data/ca-certificates.crt
Stripestripe for Rubygems/stripe-<version>/lib/data/ca-certificates.crt
Stripestripe/stripe-phpvendor/stripe/stripe-php/data/ca-certificates.crt
PayPalpaypal-sdk-rest for Rubygems/paypal-sdk-rest-<version>/data/paypal.crt

It finds the file wherever the package is installed: a virtual environment, the system site-packages, a pip install --target folder, and every Python version the image holds.

  1. rystic compose up, run, create, watch and scale first build or pull an image that isn’t there yet, so the image read is the one that runs. --build rebuilds first.
  2. --no-build, --dry-run, pull, config and generate read only images already on this machine. A failed build or an unreadable image gives a warning for that app, and the run goes on.
  3. A package your Compose file mounts from the host, such as a vendor/ folder, isn’t in the image: add its mount by hand.

With rystic export compose, give the export your app’s built image:

docker compose -f compose.yaml build app
rystic export compose -o ./deploy --app-image app=shop-app
# -> wrote .env.example, docker-compose.yaml to ./deploy

shop-app is the image Compose built for app: by default <project>-<service>, where the project is the folder name of your first Compose file. docker compose -f compose.yaml images app prints it. Export again after a rebuild that changes the SDK’s version or the Python version, since the file’s path depends on both. --app-image reads only an image on this machine, so build it first; an image that isn’t there stops the export.

Without --app-image, the exported file’s header names each file the stack’s simulators declare, with the mount to add to your app’s service:

# compose.yaml
services:
  app:
    build: .
    volumes:
      - type: volume
        source: rystic-ca
        target: /usr/local/lib/python3.12/site-packages/stripe/data/ca-certificates.crt
        read_only: true
        volume: {subpath: bundle.pem, nocopy: true}

For an SDK not in the table, set its CA option in code, or mount bundle.pem over its file the same way, nocopy: true included.

In CI

A CI job runs the same commands as your machine: install the CLI, start each simulator with --intercept and run the tests under rystic exec. On GitHub Actions, with the API key stored as the RYSTIC_TOKEN secret (One secret):

# .github/workflows/intercept.yml
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    env:
      RYSTIC_TOKEN: ${{ secrets.RYSTIC_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: {node-version: 24}
      - run: npm ci
      - run: curl -fsSL https://www.rystic.ai/install.sh | RYSTIC_BIN="$HOME/.local/bin" sh
      - run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
      - run: rystic run stripe-twin --intercept -d --name stripe --port 0
      - run: rystic exec --strict -- npm test
  1. The CLI reads the key from RYSTIC_TOKEN, so the job needs no rystic login.
  2. The job pins Node 24, a release that reads the proxy variables (What each runtime reads).
  3. --strict refuses a call through the gateway to a host no simulator claims, so the test fails rather than reach the real host. It does not stop a client that ignores the proxy: Clients that need one more step. --allow <host> lets one host through.
  4. The detached simulator outlives the step that started it, and the job’s end stops it.
  5. To run your app as an image instead, use the simulator as a service container by base URL: Integration tests in CI.

Browsers

A browser ignores the proxy variables, so what a test browser loads itself, such as Stripe’s hosted Checkout or Clerk’s sign-in script, goes to the vendor. --browser playwright hands Playwright the settings that send it through the gateway. With stripe from the Quick start running:

rystic gateway --stop    # a gateway already running with other --strict or --allow settings refuses the exec
rystic exec --strict --browser playwright -- npx playwright test
# -> 2 passed

One block in the Playwright config reads them:

// playwright.config.mjs
import { defineConfig, devices } from '@playwright/test';

const rystic = JSON.parse(process.env.RYSTIC_PLAYWRIGHT ?? '{}');

export default defineConfig({
  webServer: { command: 'node app.mjs', url: 'http://localhost:3000/' },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'], launchOptions: rystic.chromium } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'], launchOptions: rystic.firefox } },
  ],
});

The app and the test, unchanged from a run against Stripe:

// app.mjs: /subscribe creates a Checkout Session and redirects to its url
import http from 'node:http';

const stripe = async (path, form) => {
  const res = await fetch(`https://api.stripe.com/v1/${path}`, {
    method: 'POST',
    headers: { Authorization: 'Bearer sk_test_anything' },
    body: new URLSearchParams(form),
  });
  return res.json();
};

http.createServer(async (req, res) => {
  if (req.url !== '/subscribe') return res.end('<h1>subscribed</h1>');
  const product = await stripe('products', { name: 'Pro' });
  const price = await stripe('prices', {
    product: product.id, unit_amount: 1500, currency: 'usd', 'recurring[interval]': 'month',
  });
  const session = await stripe('checkout/sessions', {
    mode: 'subscription', 'line_items[0][price]': price.id, 'line_items[0][quantity]': 1,
    success_url: 'http://localhost:3000/done', cancel_url: 'http://localhost:3000/',
  });
  res.writeHead(303, { Location: session.url }).end();
}).listen(3000);
// tests/checkout.spec.mjs
import { test, expect } from '@playwright/test';

test('subscribes on hosted Checkout', async ({ page }) => {
  await page.goto('http://localhost:3000/subscribe');
  await expect(page).toHaveURL(/^https:\/\/checkout\.stripe\.com\/c\/pay\//);
  await page.fill('#email', 'buyer@example.com');
  await page.fill('#card_number', '4242 4242 4242 4242');
  await page.fill('[name=card_expiry]', '12 / 34');
  await page.fill('[name=card_cvc]', '123');
  await page.fill('#name', 'Pat Buyer');
  await page.click('button[type=submit]');
  await expect(page).toHaveURL(/^http:\/\/localhost:3000\/done/);
});
  1. RYSTIC_PLAYWRIGHT holds each browser’s launch options as JSON: the gateway as its proxy, and for Chromium the hash of the CA’s public key. Outside rystic exec it is unset, and the browsers launch as they always do.
  2. Playwright starts the app under the same rystic exec, so the app’s own calls to api.stripe.com reach the simulator too. The gateway log shows both: POST api.stripe.com/v1/checkout/sessions → 200 from the app, then GET checkout.stripe.com/c/pay/… from the browser.
  3. Under --strict, a page that loads a host no simulator claims fails to load it rather than reach the vendor: What a browser reaches. A host the page needs that no simulator claims, such as a font or script CDN, takes --allow.
  4. eval "$(rystic env --browser playwright)" sets the same in your shell. rystic env --browser playwright --json prints the options under data.playwright, keyed by browser.

How each browser trusts the CA

browsertrusts the gateway’s certificates through
Chromiumthe --ignore-certificate-errors-spki-list argument, set to the hash of the Rystic CA’s public key. Chromium then accepts any certificate chain that carries the Rystic CA, for any host. A site’s own certificate still checks as usual, but on a gateway that isn’t strict a party on the path to a host the gateway passes through, holding your ca.pem, could stand in for that host, and so could one on the path to an --allow host. Run browser tests with --strict. --browser playwright warns when the gateway passes hosts through: it names each --allow host, or tells you to add --strict
FirefoxPLAYWRIGHT_FIREFOX_POLICIES_JSON, which --browser playwright also sets. Playwright’s Firefox reads the policy file it names at launch, and the policy installs ca.pem as a trusted root
WebKitnothing: Playwright has no launch option for it, so WebKit refuses the simulated hosts with The certificate for this server is invalid. Run those tests on Chromium or Firefox

What a browser reaches

SimulatorServed to a browserNot routed, or not served
Stripehosted Checkout for a subscription Session on checkout.stripe.com, and the customer portal on billing.stripe.com: Hosted Checkout and customer portalStripe.js on js.stripe.com and its frames on m.stripe.network, which no simulator claims. The hosted invoice and receipt pages return 404
Clerkthe companion’s /clerk.js, /clerk-ui.js and /clerk.css on any clerk.accounts.dev host: Browser companionClerk’s hosted sign-in pages on accounts.dev, and @clerk/clerk-js from Clerk’s own script path. Point the app at the companion’s script instead
GitHubavatars on avatars.githubusercontent.comthe sign-in and OAuth authorization pages on github.com

Which hosts each simulator claims

SimulatorHosts
Slackslack-files.com, slack.com
GitHubavatars.githubusercontent.com, github.com, release-assets.githubusercontent.com
Kalshiapi.elections.kalshi.com, demo-api.kalshi.co, external-api-ws.demo.kalshi.co, external-api-ws.kalshi.com, external-api.demo.kalshi.co, external-api.kalshi.com
PayPalapi-m.paypal.com, api-m.sandbox.paypal.com, api.sandbox.paypal.com, developer.paypal.com, www.paypal.com, www.sandbox.paypal.com
Lobapi.lob.com
Oktaokta-emea.com, okta-gov.com, okta.com, okta.mil, oktapreview.com
Linearapi.linear.app
Stripeapi.stripe.com, billing.stripe.com, buy.stripe.com, checkout.stripe.com, invoice.stripe.com, pay.stripe.com, payments.stripe.com
Resendapi.resend.com
Airtableairtable.com, api.airtable.com, content.airtable.com, v5.airtableusercontent.com
Anthropicapi.anthropic.com
Clerkapi.clerk.com, clerk.accounts.dev, img.clerk.com
Dropboxapi.dropboxapi.com, content.dropboxapi.com, notify.dropboxapi.com
Gmailaccounts.google.com, gmail.googleapis.com, oauth2.googleapis.com, openidconnect.googleapis.com; shares a host with Google Drive: run one of them per project
Google Driveaccounts.google.com, oauth2.googleapis.com, openidconnect.googleapis.com, www.googleapis.com; shares a host with Gmail: run one of them per project
Jiraatlassian.net
Modalapi.modal.com, blobs.modal.com, duot2hadvvkdh.cloudfront.net, input-plane.us-east.modal.com, w.modal.host
Notionapi.notion.com
PostHogeu.posthog.com, us.i.posthog.com, us.posthog.com
QuickBooks Onlinequickbooks.api.intuit.com, sandbox-quickbooks.api.intuit.com
S3s3.amazonaws.com, s3.us-east-1.amazonaws.com
Shopifymyshopify.com
Wordnone: point the client at the simulator’s URL
  1. A host covers its subdomains, so a workspace, organization, bucket or store host routes where the host above it does.
  2. Everything else is tunneled to the vendor, or refused under --strict. That includes a regional or custom-domain host the table does not list: point that client’s base URL at the simulator instead.
  3. rystic run --intercept prints a simulator’s hosts on its next: line, and rystic describe <product> on its hosts: line. A simulator with no hosts prints declares no service hosts, so the gateway has nothing to route to it.
  4. In a rystic grid -evals cell, the agent reaches a simulator with no hosts at the URL the cell hands it: Grade agent runs → Simulators without a claimed host.

Limits

What isn’t intercepted

  1. On the host and in a single container, a client that ignores the proxy variables, or brings its own HTTP agent, connects straight to the vendor. See Clients that need one more step. Nothing the gateway does stops that, --strict included. In Docker Compose the gateway’s aliases reach such a client in a wired app too. They miss one that calls a hard-coded IP address or resolves names over HTTPS, and Java needs the CA in its own trust store.
  2. Hosts that no simulator claims, and the hosts of a simulator started without --intercept.
  3. Clients that verify against a CA file of their own, as stripe for Python does, until you point them at the bundle. In Docker Compose rystic compose mounts the bundle over that file.
  4. HTTP/2. Intercepted connections negotiate HTTP/1.1.
  5. A browser launched without the settings in Browsers: it ignores the proxy variables.

How a call fails

you seeit meansdo this
curl: (56) CONNECT tunnel failed, response 403, or Python’s Tunnel connection failed: 403 Forbiddena simulated host with no --intercept simulator in this project. The gateway log, and the body of a plain http:// call, name it: api.notion.com is simulated by notion-twin, and none runs with --intercept in project default — start it: rystic run notion-twin --intercept -d --project defaultrun that line, or match --project
502: api.stripe.com is claimed by two twins, stripe-twin/a (…) and stripe-twin/b (…) — stop one, or run it under another --projecttwo --intercept simulators in one project claim the host. Other hosts still routestop one, or give it its own --project
rystic: the gateway exited at start — its log: … (exit 1)the gateway refused to start. The log names why, for example the claim conflict abovefix what the log names
502: … did not answer: … connection refusedthe simulator stopped in the last two seconds. After that, the call is the 403 abovestart it again
self-signed certificate in certificate chain, certificate signed by unknown authority. The gateway log shows TLS for <host> failed … (a client that rejects the certificate does not trust the Rystic CA)the client doesn’t read the CA variables, or pins its ownWhat each runtime reads
the vendor’s own error, such as Invalid API Key provided or InvalidAccessKeyIdthe call reached the real vendor. The log shows no CONNECT for it, or a tunnel <host> lineClients that need one more step, or check the host table. From a Compose app calling a subdomain, add it to gateway: {hosts}
the gateway for project default (pid …) already runs without --strict (exit 9)exec, env or a stack file’s gateway key asked for a different policy than the running gatewayrystic gateway --stop, then ask again
curl: (56) CONNECT tunnel failed, response 403 from a Compose gateway, which logs slack.com is simulated by slack-twin, and this gateway has no --upstream for itthe gateway has no --upstream for that simulatoradd the simulator to the stack with intercept: true, or an --upstream to the gateway’s command
a Compose gateway that never turns healthy and logs flag provided but not defined: -listen-tlsthe image the rystic-gateway service runs, which the file’s header names, carries a CLI older than --listen-tlspin that simulator to a newer version and export again
getaddrinfo EAI_AGAIN <bucket>.s3.us-east-1.amazonaws.com, or curl: (6) Could not resolve host, from a Compose appthe host has no alias: a subdomain the client builds, or a host no Rystic simulator covers, on a network with no route outadd the subdomain to gateway: {hosts} and export again. Any other host stays unresolved there
Could not verify Stripe's SSL certificate from a Compose app with the overlaythe SDK verifies against a CA file it shipsrun it with rystic compose up, or export again with --app-image (SDKs that ship their own CA file)
a rystic compose gateway that exits at start and logs flag provided but not defined: -forwarda port of yours moved onto the gateway, whose image carries a CLI older than --forwardpin that simulator to a newer version
tlsv1 unrecognized name from a Compose app, and the gateway logs refused TLS for <host>:the client’s DNS sends the host to the gateway, which routes no simulator for it. The log says why: no simulator claims it, or the simulator that does has no --upstreamdrop the alias you wrote, or add that simulator with intercept: true (rystic compose add <simulator>), or an --upstream to the gateway’s command
self-signed certificate in certificate chain or PKIX path building failed from a Compose app with the overlay, and the gateway logs transparent TLS from … failedthe client reads its own trust store, not the system store or the CA variablespoint that store at /rystic-ca/bundle.pem, or import /rystic-ca/ca.pem into it (Clients that need one more step)

Hosts no simulator claims

By default the gateway tunnels them to the real host without decrypting them, so your app’s other calls keep working. --strict refuses them instead:

rystic gateway --stop
# -> stopped the gateway for project default (pid ...)
rystic exec --strict -- curl -s http://example.com/
# -> example.com is not simulated, and this gateway is --strict — allow it with --allow example.com

--allow lets one host through. Stop the gateway first, because it holds one policy:

rystic gateway --stop
# -> stopped the gateway for project default (pid ...)
rystic exec --strict --allow example.com -- ./run-tests.sh
  1. One gateway serves a project with one policy. To switch between --strict and the default, run rystic gateway --stop first. exec and env without --strict or --allow keep the policy the project’s gateway last ran with.
  2. --strict applies to requests that reach the gateway. A client that connects directly isn’t affected.

Next

  1. CLI reference: every flag of exec, env, gateway and trust.
  2. Boot configuration: RYSTIC_PRESERVE_SERVICE_URLS, which --intercept sets.
  3. Integration tests in CI: the simulator as a service container, by base URL.
Last updated on