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
rystic run <product> --interceptboots the simulator for the gateway. The URLs it hands back keep the vendor’s hosts, such as PayPal’slinks, Lob’snext_urland GitHub’shtml_url, instead of naminglocalhost. A client that follows one comes back through the gateway.- The gateway: one per project, listening on
127.0.0.1only. For each host that an--interceptsimulator in the project claims, it terminates TLS with a certificate from the Rystic CA and forwards the request to that simulator,Hostunchanged. It re-reads the simulators as requests arrive, so it picks up a simulator started or stopped later without a restart. 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.eval "$(rystic env)"puts the same exports in your shell, so every later command in it is routed.rystic gatewayruns the gateway in the foreground and logs to the terminal.--portfixes its port, andexecandenvuse it while it runs.Ctrl-Cends 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
- Starts on the first
rystic execorrystic envin a project with no gateway running, or on arystic upwhose stack file has anintercept: trueservice. - Listens on a free port on
127.0.0.1.rystic envprints it. - Is recorded in
~/.rystic/run/gateway/<project>.json. - Logs to
~/.rystic/run/gateway/<project>.log, one line per connection and per request. - Stops on
rystic gateway --stoporrystic down.rystic stopleaves 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
- The top-level
gatewaykey takesstrictandallow, the same policy as--strictand--allow.allowneedsstrict: true, and a file withgatewaybut nointercept: trueservice exits 2. rystic execandrystic envwithout--strictor--allowkeep the policy the project’s gateway last ran with, sorystic exec --project shopis strict here. The policy holds even after the gateway stops unexpectedly, in a crash, a signal or a reboot. Onlyrystic gateway --stoporrystic downclears it, and the next gateway starts without--strict.rystic downstops the gateway with the simulators.- A service already running with a different
interceptsetting stopsup(exit 9), naming the service. Stop it, then runupagain.
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
bundle.pemholds your system’s roots plus the Rystic gateway CA, so hosts the gateway passes through still verify.ca.pemis the CA alone.NO_PROXYkeeps calls to a simulator’s ownlocalhostport off the gateway.GODEBUGis appended to any value you already set.rystic env --jsonprints the same underdata.env, with the gateway’s URL, pid, CA, bundle and log paths.- The first
execorenvcreates 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
| client | trusts the CA through |
|---|---|
| curl | CURL_CA_BUNDLE, else SSL_CERT_FILE |
| git | GIT_SSL_CAINFO |
Python urllib and ssl, and libraries built on them such as slack_sdk | SSL_CERT_FILE |
Python requests | REQUESTS_CA_BUNDLE, else CURL_CA_BUNDLE |
| boto3, AWS CLI | AWS_CA_BUNDLE |
Python httplib2, and google-api-python-client on it | HTTPLIB2_CA_CERTS |
Node fetch, the global https agent and SDKs that use them, such as @slack/web-api | NODE_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::HTTP | SSL_CERT_FILE |
| Go | on 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
| client | unchanged, it… | make it route |
|---|---|---|
stripe for Python | verifies TLS against the CA file it ships and reads no CA variable: APIConnectionError: Could not verify Stripe's SSL certificate | stripe.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-php | verify TLS against the CA file they ship | Stripe.ca_bundle_path = ENV["SSL_CERT_FILE"], \Stripe\Stripe::setCABundlePath(getenv('SSL_CERT_FILE')), or in Compose, no change |
paypal-sdk-rest for Ruby | verifies TLS against the CA file it ships | ssl_options: { ca_file: ENV["SSL_CERT_FILE"] } in PayPal::SDK.configure, or in Compose, no change |
stripe for Node | brings its own agent and reaches Stripe directly: StripeAuthenticationError: Invalid API Key provided | new Stripe(key, { httpAgent: https.globalAgent }) |
@paypal/paypal-server-sdk with an older axios, which the library’s own range still admits | sends HTTPS requests in a form the gateway refuses with 400 | npm install axios@latest beside it |
| AWS SDK for JavaScript v3 | brings its own agent and reaches AWS directly: InvalidAccessKeyId | new S3Client({ …, requestHandler: { httpsAgent: https.globalAgent } }) |
Java HttpClient | ignores 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_FAILED | a Python built on OpenSSL, such as Homebrew’s |
Go before 1.27 on macOS, Homebrew gh among them | x509: certificate signed by unknown authority | rystic 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
- The CA’s name constraints confine it to the simulated hosts, so trusting it vouches for no other site.
- When a newer
rysticsimulates more hosts, it replaces the CA and says so. Runrystic trustagain. - On Linux,
SSL_CERT_FILEcarries the CA andrystic trustchanges 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:
rystic execruns your command as a child process rather than replacing itself. It passesCtrl-Con and exits with the command’s exit code.rystic envprintsexportlines, for a POSIX shell such as Git Bash. In PowerShell orcmd, set the variablesrystic env --jsonlists underdata.env.rystic trustchanges nothing. Go tools built before Go 1.27 needca.pem, the file underdata.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"...}
- On Docker Engine for Linux, a container reaches the host’s
127.0.0.1only with--network host. Run it that way and keep the gateway URL asrystic envprints it. Docker Desktop for Linux works as on a Mac. - Set the CA variable your client reads (What each runtime reads) to a mounted file, since the host paths in
rystic envdon’t exist inside the container. A variable that replaces the trust store, such asSSL_CERT_FILE, takesbundle.pem(data.bundle), so hosts the gateway passes through still verify.NODE_EXTRA_CA_CERTSandcurl --cacerttakeca.pem(data.ca). - The simulators run on the host, so the gateway reaches them as it always does.
- 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.
-
The
rystic-gatewayservice runsrystic 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--upstreamroutes that simulator’s hosts to its service by name, for examplestripe-twin=http://stripe:8080. That image must be a release whose CLI has--listen-tls; an older one exits at start. -
--listen 0.0.0.0:3128accepts proxy clients from the Compose network. The export also publishes it on your machine’s127.0.0.1, at the portdocker compose port rystic-gateway 3128prints: The network. Without--listen, the gateway listens on127.0.0.1only. -
--listen-tls :443accepts direct TLS and routes it by the host the client names. The gateway’saliasesgive it every exact host the simulators claim on therystic-interceptnetwork, and, unlessegressisopen, every other vendor host a Rystic simulator covers, which it refuses. So a client that ignoresHTTPS_PROXY, such asstripefor Node or the AWS SDK for JavaScript v3, reaches the simulator with no change. A host the gateway doesn’t route fails the handshake withunrecognized_name. -
The gateway creates its CA in memory each time it starts, and writes only the public
ca.pemandbundle.pem(its system roots plus the CA) to--ca-out, therystic-cavolume. The private key never leaves the gateway. A restarted gateway has a new CA, so restart your app after it. -
The
appoverlay setsHTTPS_PROXYand every CA variablerystic execsets (What each runtime reads). SetNO_PROXYin your own file, withlocalhost,127.0.0.1,::1, to reach your own HTTPS services directly. Withoutapps, the exported file’s header lists this wiring to add by hand. -
The overlay also mounts
bundle.pemread-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. Itsnocopy: truestops Docker 28 and older from trying to copy the image’s own file into the volume, which fails. -
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 withgateway: {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 -
gateway: {strict: true}becomes--strict, and eachallowhost 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--upstreamis 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 withgateway: {egress: open}reaches the real host. -
Each simulator mounts
rystic-<service>-data, and on an API keyrystic-<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.
- 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 ingateway: {apps}, or give itnetworks: [default, rystic-intercept]in your file and declarerystic-intercept: {internal: true}undernetworks. - 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 composesetsHOSTNAME=0.0.0.0on each wired app unless your files orapp_envset 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
- 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 composemoves 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. gateway: {egress: open}keeps Compose’s own default network, with a route out. The proxy is still published.- The Antithesis export has no route out either way, and
egress: openthere 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:
| simulator | SDK | the file, under the package’s folder |
|---|---|---|
| Stripe | stripe for Python | site-packages/stripe/data/ca-certificates.crt |
| Stripe | stripe for Ruby | gems/stripe-<version>/lib/data/ca-certificates.crt |
| Stripe | stripe/stripe-php | vendor/stripe/stripe-php/data/ca-certificates.crt |
| PayPal | paypal-sdk-rest for Ruby | gems/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.
rystic compose up,run,create,watchandscalefirst build or pull an image that isn’t there yet, so the image read is the one that runs.--buildrebuilds first.--no-build,--dry-run,pull,configandgenerateread only images already on this machine. A failed build or an unreadable image gives a warning for that app, and the run goes on.- 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
- The CLI reads the key from
RYSTIC_TOKEN, so the job needs norystic login. - The job pins Node 24, a release that reads the proxy variables (What each runtime reads).
--strictrefuses 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.- The detached simulator outlives the step that started it, and the job’s end stops it.
- 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/);
});
RYSTIC_PLAYWRIGHTholds each browser’s launch options as JSON: the gateway as its proxy, and for Chromium the hash of the CA’s public key. Outsiderystic execit is unset, and the browsers launch as they always do.- Playwright starts the app under the same
rystic exec, so the app’s own calls toapi.stripe.comreach the simulator too. The gateway log shows both:POST api.stripe.com/v1/checkout/sessions → 200from the app, thenGET checkout.stripe.com/c/pay/…from the browser. - 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. eval "$(rystic env --browser playwright)"sets the same in your shell.rystic env --browser playwright --jsonprints the options underdata.playwright, keyed by browser.
How each browser trusts the CA
| browser | trusts the gateway’s certificates through |
|---|---|
| Chromium | the --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 |
| Firefox | PLAYWRIGHT_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 |
| WebKit | nothing: 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
| Simulator | Served to a browser | Not routed, or not served |
|---|---|---|
| Stripe | hosted Checkout for a subscription Session on checkout.stripe.com, and the customer portal on billing.stripe.com: Hosted Checkout and customer portal | Stripe.js on js.stripe.com and its frames on m.stripe.network, which no simulator claims. The hosted invoice and receipt pages return 404 |
| Clerk | the companion’s /clerk.js, /clerk-ui.js and /clerk.css on any clerk.accounts.dev host: Browser companion | Clerk’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 |
| GitHub | avatars on avatars.githubusercontent.com | the sign-in and OAuth authorization pages on github.com |
Which hosts each simulator claims
| Simulator | Hosts |
|---|---|
| Slack | slack-files.com, slack.com |
| GitHub | avatars.githubusercontent.com, github.com, release-assets.githubusercontent.com |
| Kalshi | api.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 |
| PayPal | api-m.paypal.com, api-m.sandbox.paypal.com, api.sandbox.paypal.com, developer.paypal.com, www.paypal.com, www.sandbox.paypal.com |
| Lob | api.lob.com |
| Okta | okta-emea.com, okta-gov.com, okta.com, okta.mil, oktapreview.com |
| Linear | api.linear.app |
| Stripe | api.stripe.com, billing.stripe.com, buy.stripe.com, checkout.stripe.com, invoice.stripe.com, pay.stripe.com, payments.stripe.com |
| Resend | api.resend.com |
| Airtable | airtable.com, api.airtable.com, content.airtable.com, v5.airtableusercontent.com |
| Anthropic | api.anthropic.com |
| Clerk | api.clerk.com, clerk.accounts.dev, img.clerk.com |
| Dropbox | api.dropboxapi.com, content.dropboxapi.com, notify.dropboxapi.com |
| Gmail | accounts.google.com, gmail.googleapis.com, oauth2.googleapis.com, openidconnect.googleapis.com; shares a host with Google Drive: run one of them per project |
| Google Drive | accounts.google.com, oauth2.googleapis.com, openidconnect.googleapis.com, www.googleapis.com; shares a host with Gmail: run one of them per project |
| Jira | atlassian.net |
| Modal | api.modal.com, blobs.modal.com, duot2hadvvkdh.cloudfront.net, input-plane.us-east.modal.com, w.modal.host |
| Notion | api.notion.com |
| PostHog | eu.posthog.com, us.i.posthog.com, us.posthog.com |
| QuickBooks Online | quickbooks.api.intuit.com, sandbox-quickbooks.api.intuit.com |
| S3 | s3.amazonaws.com, s3.us-east-1.amazonaws.com |
| Shopify | myshopify.com |
| Word | none: point the client at the simulator’s URL |
- A host covers its subdomains, so a workspace, organization, bucket or store host routes where the host above it does.
- 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. rystic run --interceptprints a simulator’s hosts on itsnext:line, andrystic describe <product>on itshosts:line. A simulator with no hosts printsdeclares no service hosts, so the gateway has nothing to route to it.- In a
rystic grid -evalscell, 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
- 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,
--strictincluded. 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. - Hosts that no simulator claims, and the hosts of a simulator started without
--intercept. - Clients that verify against a CA file of their own, as
stripefor Python does, until you point them at the bundle. In Docker Composerystic composemounts the bundle over that file. - HTTP/2. Intercepted connections negotiate HTTP/1.1.
- A browser launched without the settings in Browsers: it ignores the proxy variables.
How a call fails
| you see | it means | do this |
|---|---|---|
curl: (56) CONNECT tunnel failed, response 403, or Python’s Tunnel connection failed: 403 Forbidden | a 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 default | run 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 --project | two --intercept simulators in one project claim the host. Other hosts still route | stop 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 above | fix what the log names |
502: … did not answer: … connection refused | the simulator stopped in the last two seconds. After that, the call is the 403 above | start 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 own | What each runtime reads |
the vendor’s own error, such as Invalid API Key provided or InvalidAccessKeyId | the call reached the real vendor. The log shows no CONNECT for it, or a tunnel <host> line | Clients 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 gateway | rystic 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 it | the gateway has no --upstream for that simulator | add 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-tls | the image the rystic-gateway service runs, which the file’s header names, carries a CLI older than --listen-tls | pin 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 app | the host has no alias: a subdomain the client builds, or a host no Rystic simulator covers, on a network with no route out | add 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 overlay | the SDK verifies against a CA file it ships | run 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: -forward | a port of yours moved onto the gateway, whose image carries a CLI older than --forward | pin 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 --upstream | drop 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 … failed | the client reads its own trust store, not the system store or the CA variables | point 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
- One gateway serves a project with one policy. To switch between
--strictand the default, runrystic gateway --stopfirst.execandenvwithout--strictor--allowkeep the policy the project’s gateway last ran with. --strictapplies to requests that reach the gateway. A client that connects directly isn’t affected.
Next
- CLI reference: every flag of
exec,env,gatewayandtrust. - Boot configuration:
RYSTIC_PRESERVE_SERVICE_URLS, which--interceptsets. - Integration tests in CI: the simulator as a service container, by base URL.