Skip to content

Commit 893971c

Browse files
authored
fix: Use native root certs, falling back to pki if they fail to load (#107)
1 parent 9cc74e2 commit 893971c

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

eventsource-client/src/transport_hyper.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,7 @@ impl HyperTransport {
146146
hyper_rustls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>,
147147
>,
148148
> {
149-
use hyper_rustls::HttpsConnectorBuilder;
150-
151-
let connector = HttpsConnectorBuilder::new()
152-
.with_webpki_roots()
153-
.https_or_http()
154-
.enable_http1()
155-
.enable_http2()
156-
.build();
157-
158-
let timeout_connector = TimeoutConnector::new(connector);
159-
let client = HyperClient::builder(TokioExecutor::new()).build(timeout_connector);
160-
161-
HyperTransport { client }
149+
HyperTransport::builder().build_https()
162150
}
163151

164152
/// Create a new builder for configuring HyperTransport
@@ -246,7 +234,11 @@ impl HyperTransportBuilder {
246234
use hyper_rustls::HttpsConnectorBuilder;
247235

248236
let connector = HttpsConnectorBuilder::new()
249-
.with_webpki_roots()
237+
.with_native_roots()
238+
.unwrap_or_else(|_| {
239+
log::debug!("Falling back to webpki roots for HTTPS connector");
240+
HttpsConnectorBuilder::new().with_webpki_roots()
241+
})
250242
.https_or_http()
251243
.enable_http1()
252244
.enable_http2()

0 commit comments

Comments
 (0)