Skip to content

Instantly share code, notes, and snippets.

@p-jackson
Created July 14, 2016 11:34
Show Gist options
  • Save p-jackson/198dd5de05b53d14b533d272f2eaefce to your computer and use it in GitHub Desktop.
Save p-jackson/198dd5de05b53d14b533d272f2eaefce to your computer and use it in GitHub Desktop.
Https with hyper on Windows without using OpenSSL
[dependencies]
schannel = "0.0.2"
[dependencies.hyper]
version = "0.7"
default-features = false
extern crate hyper;
extern crate schannel;
use std::sync::Arc;
use std::io::Read;
use hyper::Client;
use hyper::net::HttpsConnector;
use schannel::hyperimpl::Schannel;
use schannel::{SslInfo, SslInfoClient};
fn main() {
let sslinfo = SslInfo::Client(SslInfoClient::new());
let schan = Schannel { info: Arc::new(sslinfo) };
let connector = HttpsConnector::<Schannel>::new(schan);
let client = Client::with_connector(connector);
let mut res = client.get("https://github.com").send().unwrap();
let mut body = String::new();
res.read_to_string(&mut body).unwrap();
println!("{}", body);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment