Optional **rustls** TLS backend for `spacetimedb-sdk`
spacetimedb-sdk currently hard‑codes the native-tls / OpenSSL stack. That forces every downstream project to carry a C tool‑chain and OpenSSL dev headers for each target architecture (for example, macOS → Linux ARM cross‑builds or static musl builds).
The extra native dependencies:
- Complicate CI images and local development setups
- Slow down compile times and increase binary size
- Break on minimal containers that lack OpenSSL
Providing an optional rustls backend would eliminate those external C requirements and bring spacetimedb-sdk in line with the pure‑Rust TLS defaults used by many modern networking crates.
Thanks for considering!
Thank you for filing this! We do also have a separate issue to remove the openssl dependency entirely (https://github.com/clockworklabs/SpacetimeDB/issues/1504), although the open PR adds a dependency on cmake on Windows. Would that make you more or less happy?
Thanks for responding!
I don't use Windows (MacOS + Linux), but I think if I did I'd still prefer a CMake build dep vs an OpenSSL runtime dep.
FYI, this is currently blocking development of a web frontend I'd like to make with Dioxus (webapps in Rust).
It's not terrible, because we're focused on native first, but it would be nice to have this unblocked in the next ~month - any chance of that?
prioritization note: we suspect that it might be better to expose feature flags to control tungstenite's choice of roots here, rather than just removing openssl since that might not address the root issue.
Thanks for bumping this @emchristiansen - we believe we'll be able to release the new feature flags in the next ~month!
Any updates here? Sorry to nag, but STDB in my Rust web app would be very nice!
Hey @emchristiansen, sorry for the delay here. We've been discussing whether we want to roll this into a full-scale removal of OpenSSL after all.
Can I ask why your webapp isn't able to use OpenSSL? Are you running on a container that doesn't support OpenSSL?
Oof, I was being dumb!
What I really want is a Rust SDK which builds for wasm.
Our app is currently desktop-only, built with Dioxus desktop – a native Rust binary rendered in a webview. The app connects directly to STDB via the Rust SDK. I would like to make this app a web app as well and reuse the same Rust client code in a Dioxus web (wasm32-unknown-unknown) build.
IIUC, the Rust SDK does websocket transport via the tokio-tungstenite crate, and the client API currently wires that up through native-tls, which is what pulls in OpenSSL.
Why not use something like tokio-tungstenite-wasm instead? I haven’t used it, but it looks like it might be a near drop-in for tokio-tungstenite at the call site, with a wasm backend that works in the browser.
If you did switch to that crate (or something similar), would there be any other hard blockers for compiling the SDK to wasm?
I would also like to build the Rust SDK to a wasm-unknown-unknown web target. Either the feature flag control of tungstenite or the tungstenite-wasm sound like they could work. Currently this is a hard blocker for wasm clients.
Hello! I would also like to request some way to remove native-tls as a dependency. It slows down compilation and complicates our docker setups. Other projects such as reqwest have begun defaulting to rustls, and it would be ideal if we could use that everywhere.
We're working on wasm build support for the Rust SDK here: https://github.com/clockworklabs/SpacetimeDB/pull/4183.
@SupernaviX to clarify, are you running the server in your docker setup, or using the Rust SDK?
@bfops specifically using the Rust SDK. We run the server using an existing docker image, so I'm not concerned about that. Compiling rust projects with native dependencies complicates our builds, and that's what I'd like to be able to avoid.
@SupernaviX Got it, thanks for the info. We'll work on removing openssl entirely but it looks like some more deps have added it since the PR was originally opened, so it's not as trivial as I was hoping.
#4183 just merged! WASM support for the Rust SDK will likely be included in the 2.1 release likely to go out next week, but may get held back if we find last-minute issues.
Assuming it makes it into the release, it can be enabled with the browser feature:
spacetimedb-sdk = { version="2.1", features=["browser"] }
Another vote for making this configurable, from a slightly different angle than the build-time and wasm cases above: OpenSSL clashes with other TLS implementations in the same binary.
Our app links BoringSSL (via libsignal), and spacetimedb-sdk is the only thing pulling in OpenSSL. Two implementations exporting the same symbols in one process is not a comfortable place to be, and it isn't something a downstream crate can work around — the backend is fixed in the SDK's dependency, so there is no feature to turn off.
Worth noting the change looks small today: native-tls is a non-optional dependency of sdks/rust, but it isn't referenced from any Rust file in the repo — it only pins a version for the tokio-tungstenite backend. So this is a manifest change rather than a code one.
We're running this on a fork, keeping native-tls as the default so nothing changes for existing users:
default = ["native-tls"]
native-tls = ["dep:native-tls", "tokio-tungstenite/native-tls"]
rustls = ["tokio-tungstenite/rustls-tls-webpki-roots"]
The workspace's shared tokio-tungstenite drops its TLS feature, and crates/cli / crates/client-api ask for native-tls themselves, so only the SDK becomes configurable.
Branch: https://github.com/fifteenlabs/SpacetimeDB/tree/fifteen/sdk-rustls — happy to open it as a PR if that shape works for you.