Skip to main content

Rustls at Ten: A TLS Library Written in Rust

· Do Minh Tuan · Developer Corner 💻

Rustls at Ten: A TLS Library Written in Rust

Rustls has turned ten. It started as a small open-source project and became a serious alternative to the C libraries that have handled encrypted web traffic for decades, with funding along the way from ISRG, AWS and Google. The next release, 0.24, is billed as a set of architectural changes around input buffering and session handling.

TLS is the protocol behind the padlock in your browser. It encrypts the connection between a client and a server, checks that the server is who it claims to be, and negotiates which cryptographic algorithms both sides will use. Every HTTPS request depends on it.

OpenSSL is the library I associate with most of that work. Rustls is the bet that writing the same thing in Rust removes a whole category of those bugs.

Why memory safety matters here

TLS libraries parse data from strangers. A client connects and sends bytes that may be malformed, truncated or deliberately hostile, and the library has to read them without falling over. That is exactly the workload where C has produced buffer overflows, use-after-free bugs and parsing errors for a long time.

Rust's ownership rules stop most of those at compile time. You cannot accidentally read freed memory, and you cannot overflow a buffer by writing past its end without the compiler complaining. That does not make a library bug-free. Logic errors, protocol mistakes and bad certificate validation are all still possible. What it removes is the specific class of memory corruption that turns a parsing bug into remote code execution.

The announcement says Rust's model virtually eliminates buffer overflows. That is fair for the class of bug, and I would not extend it to 'more secure' in general. Security is a property of the whole design, not the language.

The decade is the interesting part

I would not treat a TLS library as a weekend project. It has to track a moving standard, pass interoperability tests against every browser and client, handle certificate chains, session resumption, ALPN and a long list of edge cases. Ten years of steady work is what makes a library trustworthy, and it is why I would not switch a production stack to a new one just because its benchmark looks good.

I also pay attention to the funding. ISRG, the group behind Let's Encrypt, AWS and Google have all put money in. That is a signal that the project is infrastructure rather than a hobby, and infrastructure needs paid maintainers. I think open source security has a maintenance problem, and a library that sits in the TLS path for a large share of the web is exactly the kind of project that needs a salary behind it.

Post-quantum cryptography

Rustls has integrated post-quantum cryptography, which means key exchange designed to resist an attack from a future quantum computer.

The threat is not that someone breaks TLS today. It is that an adversary records encrypted traffic now and decrypts it later, once the hardware exists. For data with a long secret life, such as medical records or government traffic, that is a real concern, and it is why I think the move is happening before the machines arrive.

Supporting it in the library is the easy half. The hard half is deployment: which clients support the new key exchange, what happens when they do not, and whether the extra bytes in the handshake cause problems for old middleboxes. Any team enabling it should expect a period of testing, and should not assume every client on the internet will cope.

I am watching 0.24 for the next set of changes. The announcement names two things: new input buffering and improved session handling.

Input buffering sounds dull and matters a lot. A TLS server reads encrypted records from the network, and how it buffers them affects throughput and memory use under load. Better buffering means fewer copies and less waste, which shows up as latency at scale rather than in a benchmark on one connection.

Session handling is about resuming a previous connection without a full handshake. A full handshake is expensive: extra round trips, more CPU, more latency. Resumption is what makes returning visitors feel fast. The changes here are about doing that more efficiently and with better resource management, which matters for servers holding thousands of connections.

Both are the kind of improvements that no user will notice directly and every operator will feel on a busy day. That is most of what mature infrastructure work looks like.

Where I would be careful

Benchmarks for TLS libraries are notoriously dependent on the setup. Cipher suite, certificate type, hardware acceleration, connection reuse and the client used all change the result. If someone shows you a chart where Rustls is several times faster, ask what was measured. The realistic gain is often in CPU cost per handshake and memory per connection, not in raw throughput.

The other thing I would check is the ecosystem. OpenSSL has a lot of tooling, FIPS certification paths and people who have debugged it at 3am. Rustls is smaller and younger, and its API is different. If you are in a regulated environment, check the compliance story before you plan a migration.

And keep the boring advice: terminate TLS with something maintained, enable HTTPS everywhere including development, and do not write your own certificate validation. My bet is that most TLS incidents are configuration errors rather than broken cryptography.

Two things I would watch from here. Whether the 0.24 changes land without a period of regressions, which is the real test of an architectural rewrite in a security library. Whether post-quantum support becomes a default rather than an option, and how the browser ecosystem follows.

And whether the funding continues. A ten-year-old library that a large part of the web depends on deserves more than gratitude. If you run infrastructure that benefits from it, funding the maintainers is cheaper than the alternative, and it is the part of open source that companies still underinvest in.

Rustls is a good example of a project that changed the default by being patient. Ten years is a long time in this industry, and it is roughly how long it takes to be trusted with the padlock.

Written with AI assistance, reviewed and edited by Do Minh Tuan.