aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/http_loader.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-01-08 23:56:06 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-01-31 15:40:42 +0530
commitdfd746b38dcf76f28a245e3e9e4d4e60e61e6183 (patch)
treeb5d50e94f02a8e0c6d89365041f3f186b8cbfff5 /components/net/http_loader.rs
parent816a3c2d916625b1e4863da6c55167c83b58c2e1 (diff)
downloadservo-dfd746b38dcf76f28a245e3e9e4d4e60e61e6183.tar.gz
servo-dfd746b38dcf76f28a245e3e9e4d4e60e61e6183.zip
Basic certificate verification (fixes #4119)
Diffstat (limited to 'components/net/http_loader.rs')
-rw-r--r--components/net/http_loader.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs
index c5ef9e29899..ca6a252fc4d 100644
--- a/components/net/http_loader.rs
+++ b/components/net/http_loader.rs
@@ -10,8 +10,10 @@ use std::collections::HashSet;
use hyper::client::Request;
use hyper::header::common::{ContentLength, ContentType, Host, Location};
use hyper::method::Method;
+use hyper::net::HttpConnector;
use hyper::status::StatusClass;
use std::error::Error;
+use openssl::ssl::{SslContext, SslVerifyMode};
use std::io::Reader;
use std::sync::mpsc::Sender;
use util::task::spawn_named;
@@ -63,6 +65,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
redirected_to.insert(url.clone());
+
match url.scheme.as_slice() {
"http" | "https" => {}
_ => {
@@ -74,7 +77,12 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
info!("requesting {}", url.serialize());
- let mut req = match Request::new(load_data.method.clone(), url.clone()) {
+ fn verifier<'a>(ssl: &mut SslContext) {
+ ssl.set_verify(SslVerifyMode::SslVerifyPeer, None);
+ ssl.set_CA_file(&Path::new("/home/manishearth/sand/equifax"));
+ }
+
+ let mut req = match Request::with_connector(load_data.method.clone(), url.clone(), &mut HttpConnector(Some(verifier))) {
Ok(req) => req,
Err(e) => {
send_error(url, e.description().to_string(), senders);