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 ...

Get Network Programming with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.