tokio-rustls

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

Library
Cargo
v0.26.5
235 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 88
Maintenance 64
Community 80
Maturity 52
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 82
Code Quality 84
Innovation 70
Learning Curve 74

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 8 apps in this directory

Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

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
Rust 86%
Updated 1 weeks ago
Go
64%
MIT

hoop

Monitoring · Security

823

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
85
Repo Health
80
Technical
64
Dependency
Built with
Go 64%
Clojure 17%
JavaScript 11%
Updated 1 weeks ago
Dart
80%
Apache 2.0

LocalSend

Networking

92,857

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
Dart 80%
Rust 17%
Updated 5 days ago
TypeScript
88%
MIT

Mistle

AI Agents · Developer Tools

93

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

View details
68
Repo Health
76
Technical
70
Dependency
Built with
TypeScript 88%
Rust 11%
Updated 2 months ago
Go
81%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,288

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
66
Dependency
Built with
Go 81%
TypeScript 12%
Updated 4 days ago
Rust
77%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,041

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

View details
56
Repo Health
84
Technical
63
Dependency
Built with
Rust 77%
TypeScript 20%
Updated 2 months ago
Rust
98%

Stalwart

Collaboration

14,848

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
65
Dependency
Built with
Rust 98%
Updated 5 days ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,717

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
69
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 3 months ago

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