mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Add xpcshell script and warning
This commit is contained in:
parent
dfd746b38d
commit
524331d232
10 changed files with 8260 additions and 56 deletions
|
@ -7,16 +7,19 @@ use resource_task::ProgressMsg::{Payload, Done};
|
|||
|
||||
use log;
|
||||
use std::collections::HashSet;
|
||||
use file_loader;
|
||||
use hyper::client::Request;
|
||||
use hyper::header::common::{ContentLength, ContentType, Host, Location};
|
||||
use hyper::HttpError;
|
||||
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::io::{IoError, IoErrorKind, Reader};
|
||||
use std::sync::mpsc::Sender;
|
||||
use util::task::spawn_named;
|
||||
use util::resource_files::resources_dir_path;
|
||||
use url::{Url, UrlParser};
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -77,14 +80,29 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
|||
|
||||
info!("requesting {}", url.serialize());
|
||||
|
||||
fn verifier<'a>(ssl: &mut SslContext) {
|
||||
fn verifier(ssl: &mut SslContext) {
|
||||
ssl.set_verify(SslVerifyMode::SslVerifyPeer, None);
|
||||
ssl.set_CA_file(&Path::new("/home/manishearth/sand/equifax"));
|
||||
}
|
||||
let mut certs = resources_dir_path();
|
||||
certs.push("certs");
|
||||
ssl.set_CA_file(&certs);
|
||||
};
|
||||
|
||||
let mut req = match Request::with_connector(load_data.method.clone(), url.clone(), &mut HttpConnector(Some(verifier))) {
|
||||
let ssl_err_string = "[UnknownError { library: \"SSL routines\", function: \"SSL3_GET_SERVER_CERTIFICATE\",\
|
||||
reason: \"certificate verify failed\" }]";
|
||||
let mut req = match Request::with_connector(load_data.method.clone(), url.clone(),
|
||||
&mut HttpConnector(Some(box verifier as Box<FnMut(&mut SslContext)>))) {
|
||||
Ok(req) => req,
|
||||
Err(HttpError::HttpIoError(IoError {kind: IoErrorKind::OtherIoError,
|
||||
desc: "Error in OpenSSL",
|
||||
detail: Some(ref det)})) if det.as_slice() == ssl_err_string => {
|
||||
let mut image = resources_dir_path();
|
||||
image.push("badcert.html");
|
||||
let load_data = LoadData::new(Url::from_file_path(&image).unwrap(), senders.eventual_consumer);
|
||||
file_loader::factory(load_data, senders.immediate_consumer);
|
||||
return;
|
||||
},
|
||||
Err(e) => {
|
||||
println!("{:?}", e);
|
||||
send_error(url, e.description().to_string(), senders);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue