fix: gracefully handle bad native certs (#520)

Instead of failing and bailing when a bad cert is found, ignore one-off
errors for bad certs and continue to load the rest of the store.

These one-off errors mostly affect MacOS users, as found in this
rustls-native-certs issue: https://github.com/ctz/rustls-native-certs/issues/4

Fixes: #519
This commit is contained in:
Alex Pearson
2021-01-07 10:52:13 -05:00
committed by GitHub
parent a6be8363ed
commit fe4d5b9d9a
+4 -1
View File
@@ -58,7 +58,10 @@ impl TlsConnector {
#[cfg(feature = "tls-roots")]
{
config.root_store = rustls_native_certs::load_native_certs().map_err(|(_, e)| e)?;
config.root_store = match rustls_native_certs::load_native_certs() {
Ok(store) | Err((Some(store), _)) => store,
Err((None, error)) => Err(error)?,
};
}
if let Some(cert) = ca_cert {