hyper-rustls

This is an integration between the rustls TLS stack and the hyper HTTP library.

Build Status

Implementations are provided of hyper::net::SslClient, hyper::net::SslServer and hyper::net::NetworkStream.

By default clients verify certificates using the webpki-roots crate, which includes the Mozilla root CAs.

Examples

These are provided as an example of the minimal changes needed to use rustls in your existing hyper-using program.

Note that these are derived works of original hyper source, and are distributed under hyper's license.

Client

```diff --- ../hyper/examples/client.rs 2016-10-03 23:29:00.850098245 +0100 +++ examples/client.rs 2016-10-08 07:36:05.076449122 +0100 @@ -1,6 +1,8 @@ #![deny(warnings)] extern crate hyper;

+extern crate hyperrustls; + extern crate envlogger;

use std::env; @@ -8,6 +10,7 @@

use hyper::Client; use hyper::header::Connection; +use hyper::net::HttpsConnector;

fn main() { envlogger::init().unwrap(); @@ -32,7 +35,7 @@ } Client::withhttpproxy(proxy, port) }, - _ => Client::new() + _ => Client::withconnector(HttpsConnector::new(hyper_rustls::TlsClient::new())) };

 let mut res = client.get(&*url)

```

Server

```diff --- ../hyper/examples/server.rs 2016-10-03 23:29:00.850098245 +0100 +++ examples/server.rs 2016-10-08 07:31:38.720667338 +0100 @@ -1,5 +1,6 @@ #![deny(warnings)] extern crate hyper; +extern crate hyperrustls; extern crate envlogger;

use std::io::copy; @@ -41,7 +42,10 @@

fn main() { envlogger::init().unwrap(); - let server = Server::http("127.0.0.1:1337").unwrap(); + let certs = hyperrustls::util::loadcerts("examples/sample.pem"); + let key = hyperrustls::util::loadprivatekey("examples/sample.rsa"); + let tls = hyper_rustls::TlsServer::new(certs, key); + let server = Server::https("127.0.0.1:1337", tls).unwrap(); let _guard = server.handle(echo); - println!("Listening on http://127.0.0.1:1337"); + println!("Listening on https://127.0.0.1:1337"); } ```

License

hyper-rustls is distributed under the following three licenses:

These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC respectively. You may use this software under the terms of any of these licenses, at your option.