Skip to content

Commit

Permalink
tonic: gracefully handle bad native certs
Browse files Browse the repository at this point in the history
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: rustls/rustls-native-certs#4

Fixes: hyperium#519
  • Loading branch information
NAlexPear committed Jan 1, 2021
1 parent f58fcf3 commit 4d1b1bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tonic/src/transport/service/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4d1b1bb

Please sign in to comment.