tokio-rustls

Asynchronous TLS/SSL streams for the Tokio runtime, built on Rustls

Library
Cargo
v0.26.4
232stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
81/100Excellent
Development Activity92
Maintenance72
Community80
Maturity52
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality84
Innovation70
Learning Curve74

tokio-rustls bridges the Rustls pure-Rust TLS implementation with Tokio’s async I/O traits, giving Rust network code an AsyncRead/AsyncWrite TLS stream that composes with the rest of the Tokio ecosystem. It wraps a rustls::ClientConnection or rustls::ServerConnection in a TlsStream type, driving the TLS handshake and record layer asynchronously so callers can .await a connect()/accept() call instead of managing the handshake state machine by hand.

Because it delegates all cryptographic and protocol logic to Rustls, tokio-rustls stays a thin, focused adapter layer: its own source is under 1,500 lines split across a client module, a server module, and a small shared handshake driver. It underpins TLS support in a large share of the async Rust ecosystem, including HTTP clients/servers, proxies, and database drivers that need TLS without depending on OpenSSL.

What You Get

  • TlsConnector and TlsAcceptor types that wrap a Rustls ClientConfig/ServerConfig for building TLS client and server streams
  • A TlsStream<T> wrapper implementing AsyncRead/AsyncWrite over any inner async transport, most commonly a Tokio TcpStream
  • Feature flags to select the crypto backend (aws_lc_rs or ring), enable TLS 1.2 fallback, early data, or zlib/brotli certificate compression
  • Early-data (0-RTT) support for TLS 1.3 clients that need to avoid a full round trip on reconnection

Common Use Cases

  • Adding TLS termination or client TLS to a Tokio-based network service without linking against OpenSSL
  • Implementing HTTPS support in async HTTP clients/servers and reverse proxies written on top of Tokio
  • Securing database or RPC client connections that need TLS but want a pure-Rust dependency chain
  • Building custom async network protocols that need to layer TLS transparently under existing AsyncRead/AsyncWrite code

Under The Hood

Architecture - The crate is a thin async adapter: src/client.rs and src/server.rs each define a stream type wrapping a Rustls ClientConnection/ServerConnection, implementing poll_read/poll_write by driving the Rustls state machine and the underlying transport’s poll methods in lockstep; src/common/handshake.rs implements the shared connect/accept handshake future that both client and server paths reuse, and src/common/mod.rs holds the shared TlsStream buffering logic. Tech Stack - Rust 2021 edition (MSRV 1.71), with rustls as the sole required dependency (default features disabled, std feature enabled) and tokio for the async I/O traits; feature flags let consumers pick between aws_lc_rs and ring as the underlying crypto provider, and optionally enable TLS 1.2, 0-RTT early data, or certificate compression. Code Quality - tests/test.rs, tests/early-data.rs, and tests/badssl.rs (real-world TLS server) exercise handshake correctness, early data, and interop against live endpoints; the crate also runs cargo_check_external_types in CI to police its public API surface and prevent accidental leakage of internal Rustls types. Its own source is small (~1,250 lines) since it delegates all TLS protocol and cryptographic logic to Rustls. API Design - The public API mirrors std/Tokio idioms closely: TlsConnector::connect and TlsAcceptor::accept return futures that resolve to a TlsStream, so integrating it into existing async networking code is typically a one-line wrap around an existing TcpStream, with feature flags handling crypto-backend selection at compile time rather than runtime configuration.

Used by 7 apps in this directory

Rust
86%
Other

Arroyo

Data Engineering · Analytics

5,005

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust86%
Updated 1 weeks ago
Go
62%
MIT

hoop

Security · Monitoring

791

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
86
Repo Health
80
Technical
66
Dependency
Built with
Go62%
Clojure20%
JavaScript10%
Updated yesterday
Dart
80%
Apache 2.0

LocalSend

Networking

88,691

An open-source, cross-platform AirDrop alternative that sends files and messages device-to-device over your local network with no internet, no account, and no cloud server involved.

View details
89
Repo Health
61
Technical
78
Dependency
Built with
Dart80%
Rust17%
Updated today
TypeScript
88%
MIT

Mistle

AI Agents · Developer Tools

89

Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.

View details
71
Repo Health
76
Technical
71
Dependency
Built with
TypeScript88%
Rust11%
Updated 1 months ago
Go
80%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,241

Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.

View details
88
Repo Health
76
Technical
68
Dependency
Built with
Go80%
TypeScript13%
Updated today
Rust
77%
AGPL 3.0

Spacedrive

File Storage · Collaboration

38,790

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
60
Repo Health
84
Technical
65
Dependency
Built with
Rust77%
TypeScript20%
Updated 3 weeks ago
Rust
98%

Stalwart

Collaboration

14,255

All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Rust98%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search