Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove dependencies on OpenSSL #4036

Merged
merged 3 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion core/offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ keystore = { package = "substrate-keystore", path = "../keystore" }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
hyper = "0.12.35"
hyper-tls = "0.3.2"
hyper-rustls = "0.17.1"

[dev-dependencies]
env_logger = "0.7.0"
Expand Down
16 changes: 4 additions & 12 deletions core/offchain/src/api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::api::timestamp;
use bytes::Buf as _;
use fnv::FnvHashMap;
use futures::{prelude::*, channel::mpsc, compat::Compat01As03};
use log::{warn, error};
use log::error;
use primitives::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError};
use std::{fmt, io::Read as _, mem, pin::Pin, task::Context, task::Poll};

Expand Down Expand Up @@ -554,9 +554,7 @@ enum WorkerToApi {
/// Wraps around a `hyper::Client` with either TLS enabled or disabled.
enum HyperClient {
Demi-Marie marked this conversation as resolved.
Show resolved Hide resolved
/// Everything is ok and HTTPS is available.
Https(hyper::Client<hyper_tls::HttpsConnector<hyper::client::HttpConnector>, hyper::Body>),
/// We failed to initialize HTTPS and therefore only allow HTTP.
Http(hyper::Client<hyper::client::HttpConnector, hyper::Body>),
Https(hyper::Client<hyper_rustls::HttpsConnector<hyper::client::HttpConnector>, hyper::Body>),
}

impl HyperClient {
Expand All @@ -565,13 +563,8 @@ impl HyperClient {
/// By default we will try to initialize the `HttpsConnector`,
/// If that's not possible we'll fall back to `HttpConnector`.
pub fn new() -> Self {
match hyper_tls::HttpsConnector::new(1) {
Ok(tls) => HyperClient::Https(hyper::Client::builder().build(tls)),
Err(e) => {
warn!("Unable to initialize TLS client. Falling back to HTTP-only: {:?}", e);
HyperClient::Http(hyper::Client::new())
},
}
let tls = hyper_rustls::HttpsConnector::new(1);
HyperClient::Https(hyper::Client::builder().build(tls))
}
}

Expand Down Expand Up @@ -687,7 +680,6 @@ impl Future for HttpWorker {
Poll::Ready(None) => return Poll::Ready(()), // stops the worker
Poll::Ready(Some(ApiToWorker::Dispatch { id, request })) => {
let future = Compat01As03::new(match me.http_client {
HyperClient::Http(ref mut c) => c.request(request),
HyperClient::Https(ref mut c) => c.request(request),
});
debug_assert!(me.requests.iter().all(|(i, _)| *i != id));
Expand Down