mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Basic certificate verification (fixes #4119)
This commit is contained in:
parent
816a3c2d91
commit
dfd746b38d
6 changed files with 17 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue