Crate hyper_native_tls

Source
Expand description

SSL support for Hyper via the native-tls crate.

§Usage

On the client side:

extern crate hyper;
extern crate hyper_native_tls;

use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use std::io::Read;

fn main() {
    let ssl = NativeTlsClient::new().unwrap();
    let connector = HttpsConnector::new(ssl);
    let client = Client::with_connector(connector);

    let mut resp = client.get("https://google.com").send().unwrap();
    let mut body = vec![];
    resp.read_to_end(&mut body).unwrap();
    println!("{}", String::from_utf8_lossy(&body));
}

Or on the server side:

extern crate hyper;
extern crate hyper_native_tls;

use hyper::Server;
use hyper_native_tls::NativeTlsServer;

fn main() {
    let ssl = NativeTlsServer::new("identity.p12", "mypass").unwrap();
    let server = Server::https("0.0.0.0:8443", ssl).unwrap();
}

Re-exports§

Structs§

Enums§