hyper-rustls-0.6.0 doesn't have any documentation.
hyper-rustls
This is an integration between the rustls TLS stack and the hyper HTTP library.
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
+extern crate hyper_rustls;
+
extern crate env_logger;
use std::env;
use hyper::Client;
use hyper::header::Connection;
+use hyper::net::HttpsConnector;
fn main() {
env_logger::init().unwrap();
}
Client::with_http_proxy(proxy, port)
},
- _ => Client::new()
+ _ => Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new()))
};
let mut res = client.get(&*url)
#![deny(warnings)]
extern crate hyper;
Server
+extern crate hyper_rustls;
extern crate env_logger;
use std::io::copy;
fn main() {
env_logger::init().unwrap();
- let server = Server::http("127.0.0.1:1337").unwrap();
+ let certs = hyper_rustls::util::load_certs("examples/sample.pem");
+ let key = hyper_rustls::util::load_private_key("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");
}
#![deny(warnings)]
extern crate hyper;
License
hyper-rustls is distributed under the following three licenses:
- Apache License version 2.0.
- MIT license.
- ISC license.
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.