A modern TLS library written in Rust
open sourceApache-2.0 OR ISC OR MITself-hostablefree
Rustls is a TLS library written in Rust that implements TLS 1.2 and TLS 1.3 for clients and servers, aiming for good security with no configuration and no unsafe features or obsolete cryptography by default: it leaves out SSL, TLS 1.0 and 1.1, renegotiation, RC4 and cipher suites without forward secrecy. It supports post-quantum hybrid key exchange (X25519MLKEM768), TLS 1.3 0-RTT, session resumption, client authentication, OCSP stapling, raw public keys, certificate compression and client-side Encrypted Client Hello. Cryptography comes from a pluggable CryptoProvider: the project maintains providers on aws-lc-rs (recommended, with post-quantum algorithms) and ring, and third parties offer others such as Microsoft's SymCrypt; 0.23 releases select them with Cargo features (aws-lc-rs by default), while 0.24 moves them to separate crates you choose explicitly. Its website says it outperforms OpenSSL and BoringSSL when used with aws-lc-rs. Sister projects rustls-ffi (a C API) and rustls-openssl-compat (an experimental, partial libssl replacement for nginx and curl) bring it to C programs, and ISRG's Prossimo initiative has funded work on it since 2021.
Problems it solves
- replace OpenSSL in my Rust service with a memory-safe TLS implementation
- build a Rust binary with HTTPS support that doesn't need OpenSSL headers or a system libssl to compile
- cross-compile a Rust program with TLS for musl or another target where linking OpenSSL is painful
- add TLS to a custom TCP protocol server written in Rust
- our security review wants a TLS library that can't negotiate SSLv3, TLS 1.0 or weak ciphers by mistake
- turn on post-quantum key exchange for TLS connections in a Rust application
- terminate TLS with client certificate authentication (mTLS) in a Rust server
- meet a platform or compliance requirement by supplying my own crypto primitives under a Rust TLS stack
- plug Microsoft's SymCrypt or another crypto library underneath the TLS layer
- call a memory-safe TLS library from a C or C++ program
- swap nginx's TLS implementation for a memory-safe one without rebuilding nginx
- send 0-RTT early data and resume TLS 1.3 sessions to cut handshake latency
- serve OCSP-stapled certificates from my Rust TLS server
- use Encrypted Client Hello to hide which hostname a Rust client connects to
- authenticate a TLS peer with a raw public key instead of an X.509 certificate
- a TLS library with benchmarks I can run on my own hardware to compare against OpenSSL
- async TLS streams for a Tokio-based client or server
Features
- TLS 1.2 and TLS 1.3, client and server
- ECDSA, Ed25519 and RSA authentication
- ECDHE forward secrecy with curve25519, nistp256 or nistp384
- post-quantum hybrid key exchange with X25519MLKEM768
- AES-GCM and ChaCha20-Poly1305 bulk encryption
- ALPN and SNI
- TLS 1.2 session resumption and tickets (RFC 5077); TLS 1.3 resumption by tickets or session storage
- TLS 1.3 0-RTT data
- optional client authentication
- extended master secret (RFC 7627) and exporters (RFC 5705)
View 8 more
- OCSP stapling by servers
- RFC 7250 raw public keys for TLS 1.3
- RFC 8879 certificate compression
- client-side Encrypted Client Hello (ECH)
- pluggable CryptoProvider, with first-party aws-lc-rs and ring providers and third-party ones (graviola, SymCrypt)
- tunable fragment size and vectored I/O
- benchmarks for evaluating performance on your own hardware
- rustls-ffi C API and rustls-openssl-compat libssl compatibility layer as sister projects
Limitations
- Doesn't support TLS 1.0, TLS 1.1 or any SSL version: TLS 1.2 and TLS 1.3 only12
- Doesn't support TLS renegotiation1
- Doesn't accept a CA certificate used directly as a server's or client's certificate (self-signed certificates)1
- Doesn't offer cipher suites without forward secrecy, RC4, 3DES or discrete-log Diffie-Hellman1
Capabilities
| Has an API | plan not known |
|---|---|
| Takes plugins | plan not known |
| Has official SDKs | plan not known |
Alternatives
The same job
These do what Rustls does.
- OpenSSL General purpose TLS and crypto library
