Skip to content

Commit d8a025d

Browse files
committed
Log partial failures of rustls-native-certs
Continue if possible.
1 parent 35f6712 commit d8a025d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyper-rustls"
3-
version = "0.19.1"
3+
version = "0.19.2"
44
edition = "2018"
55
authors = ["Joseph Birr-Pixton <[email protected]>"]
66
license = "Apache-2.0/ISC/MIT"
@@ -11,14 +11,15 @@ repository = "https://github.com/ctz/hyper-rustls"
1111

1212
[dependencies]
1313
bytes = "0.5.2"
14+
log = "0.4.4"
1415
ct-logs = { version = "^0.6.0", optional = true }
1516
futures-util = "0.3.1"
1617
hyper = { version = "0.13.0", default-features = false }
1718
rustls = "0.16"
1819
tokio = "0.2.4"
1920
tokio-rustls = "0.12.1"
2021
webpki = "^0.21.0"
21-
rustls-native-certs = { version = "^0.1.0", optional = true }
22+
rustls-native-certs = { version = "0.2.1", optional = true }
2223

2324
[dev-dependencies]
2425
tokio = { version = "0.2.4", features = ["io-std", "macros", "dns", "stream"] }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ By default clients verify certificates using the `rustls-native-certs` crate, wh
1212
the platform's root CAs.
1313

1414
# Release history
15+
- Next release:
16+
* Use newer rustls-native-certs which works in presence of invalid certificates.
1517
- 0.19.1 (2020-01-19):
1618
* Remove dependency on hyper's tcp feature.
1719
- 0.19.0 (2019-12-17):

src/connector.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{fmt, io};
1111
use tokio::io::{AsyncRead, AsyncWrite};
1212
use tokio_rustls::TlsConnector;
1313
use webpki::DNSNameRef;
14+
use log::warn;
1415

1516
use crate::stream::MaybeHttpsStream;
1617

@@ -33,8 +34,16 @@ impl HttpsConnector<HttpConnector> {
3334
http.enforce_http(false);
3435
let mut config = ClientConfig::new();
3536
config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
36-
config.root_store = rustls_native_certs::load_native_certs()
37-
.expect("cannot access native cert store");
37+
config.root_store = match rustls_native_certs::load_native_certs() {
38+
Ok(store) => store,
39+
Err((Some(store), err)) => {
40+
warn!("Could not load all certificates: {:?}", err);
41+
store
42+
}
43+
Err((None, err)) => {
44+
Err(err).expect("cannot access native cert store")
45+
}
46+
};
3847
config.ct_logs = Some(&ct_logs::LOGS);
3948
HttpsConnector {
4049
http,

0 commit comments

Comments
 (0)