O'Reilly logo

Network Programming with Rust by Abhishek Chanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Securing tokio applications

A common problem in implementing Tokio based protocols is around securing them. Luckily, the Tokio ecosystem has tokio-tls for this. Let's look at an example of using this to secure our hyper example from a previous chapter. Here is our setup:

$ cargo new --bin tokio-tls-example

The Cargo manifest should look like this:

[package]name = "tokio-tls-example"version = "0.1.0"authors = ["Foo <foo@bar.com>"][dependencies]hyper = "0.11.7"futures = "0.1.17"net2 = "0.2.31"tokio-core = "0.1.10"num_cpus = "1.0"native-tls = "*"tokio-service = "*"tokio-proto = "*"tokio-tls = { version = "0.1", features = ["tokio-proto"] }

We will need to use the tokio-proto feature on tokio-tls to enable integration with tokio-proto. The next ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required