Skip to content

Commit

Permalink
Pass through hyper-rustls/webpki-tokio (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey authored Jun 6, 2023
1 parent 71bc925 commit 1e78775
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ default = ["rustls", "timeout", "tracing", "retry"]

retry = ["tower/retry", "futures-util"]
rustls = ["hyper-rustls"]
rustls-webpki-tokio = ["hyper-rustls/webpki-tokio"]
opentls = ["hyper-tls"]
stream = ["futures-core", "futures-util", "hyper/stream"]
timeout = ["hyper-timeout", "tokio", "tower/timeout"]
17 changes: 12 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,18 @@ impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
let mut connector = HttpConnector::new();

#[cfg(all(feature = "rustls", not(feature = "opentls")))]
let connector = HttpsConnectorBuilder::new()
.with_native_roots() // enabled the `rustls-native-certs` feature in hyper-rustls
.https_or_http() // Disable .https_only() during tests until: https://github.com/LukeMathWalker/wiremock-rs/issues/58 is resolved. Alternatively we can use conditional compilation to only enable this feature in tests, but it becomes rather ugly with integration tests.
.enable_http1()
.build();
let connector = {
let builder = HttpsConnectorBuilder::new();
#[cfg(all(feature = "rustls-webpki-tokio"))]
let builder = builder.with_webpki_roots();
#[cfg(all(not(feature = "rustls-webpki-tokio")))]
let builder = builder.with_native_roots(); // enabled the `rustls-native-certs` feature in hyper-rustls

builder
.https_or_http() // Disable .https_only() during tests until: https://github.com/LukeMathWalker/wiremock-rs/issues/58 is resolved. Alternatively we can use conditional compilation to only enable this feature in tests, but it becomes rather ugly with integration tests.
.enable_http1()
.build()
};

#[cfg(all(feature = "opentls", not(feature = "rustls")))]
let connector = HttpsConnector::new();
Expand Down

0 comments on commit 1e78775

Please sign in to comment.