Skip to content

Commit

Permalink
wip: support self signed certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
phra committed May 18, 2019
1 parent c50b4c5 commit f048143
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pretty_env_logger = "^0.3.0"
log = "^0.4.6"
futures = "^0.1.27"
hyper-tls = "^0.3.2"
native-tls = "^0.2.3"

[dependencies.clap]
version = "2.33"
Expand Down
9 changes: 7 additions & 2 deletions src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hyper_tls::{
self,
HttpsConnector
};

use native_tls;
use std::sync::mpsc::Sender;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -50,7 +50,12 @@ fn _fetch_url(
}

pub fn _run(tx: Sender<Target>, urls: Vec<hyper::Uri>, n_threads: usize) {
let https = HttpsConnector::new(n_threads).expect("TLS initialization failed");
let mut tls_connector_builder = native_tls::TlsConnector::builder();
tls_connector_builder.danger_accept_invalid_certs(true);
let tls_connector = tls_connector_builder.build().unwrap();
let http_connector = HttpConnector::new(n_threads);
let https_connector = HttpsConnector::from((http_connector, tls_connector));
let https = HttpsConnector::new(n_threads);
let client = Client::builder().build(https);

let stream = futures::stream::iter_ok(urls)
Expand Down

0 comments on commit f048143

Please sign in to comment.