hyper-sync-rustls
This is an integration between the rustls
TLS
stack and the synchronous version (0.10) of the
hyper
HTTP library. This is a maintained
fork of hyper-rustls
for synchronous
hyper.
Usage
These are provided as an example of the minimal changes needed to use rustls in your existing hyper-based program. Note that these are derived works of original hyper source, and are distributed under hyper's license.
Client
Enable the client
feature for access to client types.
+extern crate hyper_sync_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_sync_rustls::TlsClient::new()))
};
let mut res = client.get(&*url)
#![deny(warnings)]
extern crate hyper;
Server
Enable the server
feature for access to client types.
+extern crate hyper_sync_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_sync_rustls::util::load_certs("examples/sample.pem").unwrap();
+ let key = hyper_sync_rustls::util::load_private_key("examples/sample.rsa").unwrap();
+ let tls = hyper_sync_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-sync-rustls
is licensed under either of the following, at your option: