Prerequisites
- Your application running inside an Intel TDX CVM (or against the dstack simulator for local dev)
- A connection string — see Connection string
- An Intel Trust Authority API key, or the local DCAP verifier (Rust today; Python wheel pending)
Standard Postgres compatibility
Any standard Postgres client works against TeeSQL once TLS is configured correctly — see SSL & TLS. Such clients do not verify the database’s TDX attestation; they only verify the X.509 chain, which means a misconfigured operator could swap the backing CVM without the client noticing. Use a TeeSQL RA-TLS library when that matters.RA-TLS client libraries
| Language | Package | Driver | Verifier(s) |
|---|---|---|---|
| TypeScript / Node.js | prisma-ra-tls | Prisma + pg | IntelApiVerifier, NoopVerifier, custom |
| Python | psycopg-ra-tls | psycopg 3 | IntelApiVerifier, NoopVerifier (DCAP wheel pending) |
| Rust | sqlx-ra-tls | sqlx 0.8 + Postgres | DcapVerifier (default, local), IntelApiVerifier, NoopVerifier |
Minimal example
Development verifiers
In simulator mode the database’s certificate is self-signed and there is no TDX quote to verify. All three libraries ship aNoopVerifier for this case — never use it in production.
ORM integration
Prisma
prisma-ra-tls is a Prisma driver adapter. Enable the preview feature in schema.prisma:
schema.prisma
PrismaClient (see the TypeScript example above). Requires Node.js ≥ 18 and Prisma ≥ 5.10.
Drizzle, TypeORM, Sequelize, Knex, and SQLAlchemy adapters are not currently available.
Verification options
Each library exposes the same knobs for pinning the database identity:| Option | Purpose |
|---|---|
allowedMrTd / allowed_mrtds | Hex MRTD allowlist — the measurement of the database CVM image. Always pin in production. |
allowDebugMode / allow_debug_mode | Accept TDs marked debuggable. Never enable in production. |
allowSimulator / allow_simulator | Accept a self-signed cert with no TDX quote. Never enable in production. |
clientAttestation / forwarder default | Present a TDX-attested client certificate from /var/run/dstack.sock. |
cacheTtlMs (TS) | How long a successful verification is reused. Default 1 hour. |
Verifier-only libraries
If you need to verify a TDX quote without going through a database driver — for example, to check the sidecar’s/attestation endpoint — use the verification primitives directly:
- Python:
ra-tls-verify—extract_tdx_quote,IntelApiVerifier,NoopVerifier. The PythonDcapVerifierwheel is pending. - Rust:
ra-tls-parsefor cert/chain parsing intorustlstypes; quote verification viadcap-qvl(used internally bysqlx-ra-tls).
Worked example
teesql-example-python is a runnable FastAPI app that demonstrates the production shape: two long-lived psycopg connections (teesql_readwrite for writes, teesql_read for a polling task), OperationalError reconnect-once on failover, and a WebSocket fan-out backed by the secondary. Fork it as the starting point for your own service.