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

Commit b9a0835

Browse files
committed
Remove dependency on hyper-tls
This removes one of the dependencies on native-tls, and thus on OpenSSL. I will remove the other in a separate commit.
1 parent a0d368b commit b9a0835

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

Cargo.lock

+27-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/offchain/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ keystore = { package = "substrate-keystore", path = "../keystore" }
2828

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

3333
[dev-dependencies]
3434
env_logger = "0.7.0"

core/offchain/src/api/http.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::api::timestamp;
2929
use bytes::Buf as _;
3030
use fnv::FnvHashMap;
3131
use futures::{prelude::*, channel::mpsc, compat::Compat01As03};
32-
use log::{warn, error};
32+
use log::error;
3333
use primitives::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError};
3434
use std::{fmt, io::Read as _, mem, pin::Pin, task::Context, task::Poll};
3535

@@ -554,9 +554,7 @@ enum WorkerToApi {
554554
/// Wraps around a `hyper::Client` with either TLS enabled or disabled.
555555
enum HyperClient {
556556
/// Everything is ok and HTTPS is available.
557-
Https(hyper::Client<hyper_tls::HttpsConnector<hyper::client::HttpConnector>, hyper::Body>),
558-
/// We failed to initialize HTTPS and therefore only allow HTTP.
559-
Http(hyper::Client<hyper::client::HttpConnector, hyper::Body>),
557+
Https(hyper::Client<hyper_rustls::HttpsConnector<hyper::client::HttpConnector>, hyper::Body>),
560558
}
561559

562560
impl HyperClient {
@@ -565,13 +563,8 @@ impl HyperClient {
565563
/// By default we will try to initialize the `HttpsConnector`,
566564
/// If that's not possible we'll fall back to `HttpConnector`.
567565
pub fn new() -> Self {
568-
match hyper_tls::HttpsConnector::new(1) {
569-
Ok(tls) => HyperClient::Https(hyper::Client::builder().build(tls)),
570-
Err(e) => {
571-
warn!("Unable to initialize TLS client. Falling back to HTTP-only: {:?}", e);
572-
HyperClient::Http(hyper::Client::new())
573-
},
574-
}
566+
let tls = hyper_rustls::HttpsConnector::new(1);
567+
HyperClient::Https(hyper::Client::builder().build(tls))
575568
}
576569
}
577570

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

0 commit comments

Comments
 (0)