Basic certificate verification (fixes #4119)

This commit is contained in:
Manish Goregaokar 2015-01-08 23:56:06 +05:30
parent 816a3c2d91
commit dfd746b38d
6 changed files with 17 additions and 2 deletions

View file

@ -23,6 +23,9 @@ git = "https://github.com/servo/rust-png"
[dependencies.stb_image]
git = "https://github.com/servo/rust-stb-image"
[dependencies.openssl]
git = "https://github.com/sfackler/rust-openssl"
[dependencies]
url = "0.2.16"
time = "0.1.12"
time = "0.1.12"

View file

@ -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);

View file

@ -17,6 +17,7 @@ extern crate hyper;
extern crate png;
#[macro_use]
extern crate log;
extern crate openssl;
extern crate serialize;
extern crate util;
extern crate stb_image;

View file

@ -589,6 +589,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.1.0 (git+https://github.com/servo/hyper?branch=servo)",
"openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",

1
ports/cef/Cargo.lock generated
View file

@ -552,6 +552,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.1.0 (git+https://github.com/servo/hyper?branch=servo)",
"openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",

1
ports/gonk/Cargo.lock generated
View file

@ -471,6 +471,7 @@ version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.1.0 (git+https://github.com/servo/hyper?branch=servo)",
"openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",