1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
This patch is based on the upstream commit described below, adapted for
use in the Debian package by Peter Michael Green.
commit fb1f73b01a6aee6641bb22eb8c8deb892110120e
Author: nickelc <constantin.nickel@gmail.com>
Date: Wed Sep 4 12:23:01 2024 +0200
deps: update `rustls-native-certs` to 0.8 (#440)
The `load_native_certs()` function now returns all errors instead of
raising only the first error.
Not finding any native root CA certificates is not fatal if the
"rustls-tls-webpki-roots" feature is enabled.
diff --git a/Cargo.toml b/Cargo.toml
index 51902d9a82..84fb8349f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -57,5 +57,5 @@ version = "1.0"
[dependencies.rustls-native-certs]
-version = "0.7.0"
+version = "0.8.0"
optional = true
diff --git a/src/tls.rs b/src/tls.rs
index 836b7aef4d..42fb5c4196 100644
--- a/src/tls.rs
+++ b/src/tls.rs
@@ -105,10 +105,26 @@ mod encryption {
#[cfg(feature = "rustls-tls-native-roots")]
{
- let native_certs = rustls_native_certs::load_native_certs()?;
- let total_number = native_certs.len();
+ let rustls_native_certs::CertificateResult {
+ certs, errors, ..
+ } = rustls_native_certs::load_native_certs();
+
+ if !errors.is_empty() {
+ log::warn!(
+ "native root CA certificate loading errors: {errors:?}"
+ );
+ }
+
+ // Not finding any native root CA certificates is not fatal if the
+ // "rustls-tls-webpki-roots" feature is enabled.
+ #[cfg(not(feature = "rustls-tls-webpki-roots"))]
+ if certs.is_empty() {
+ return Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("no native root CA certificates found (errors: {errors:?})")).into());
+ }
+
+ let total_number = certs.len();
let (number_added, number_ignored) =
- root_store.add_parsable_certificates(native_certs);
+ root_store.add_parsable_certificates(certs);
log::debug!("Added {number_added}/{total_number} native root certificates (ignored {number_ignored})");
}
#[cfg(feature = "rustls-tls-webpki-roots")]
|