Upgrade to rustls-native-certs 0.8

This commit is contained in:
Dirkjan Ochtman 2024-09-03 10:15:35 +02:00
parent 95b32d9c29
commit d2d82ab869
2 changed files with 10 additions and 2 deletions

View File

@ -16,7 +16,7 @@ async-trait = "0.1.52"
celes = "2.1"
chrono = { version = "0.4.23", features = ["serde"] }
instant-xml = { version = "0.5", features = ["chrono"] }
rustls-native-certs = { version = "0.7", optional = true }
rustls-native-certs = { version = "0.8", optional = true }
rustls-pki-types = { version = "1", optional = true }
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["io-util", "net", "time"] }

View File

@ -215,6 +215,7 @@ mod rustls_connector {
use std::time::Duration;
use async_trait::async_trait;
use rustls_native_certs::CertificateResult;
use rustls_pki_types::{CertificateDer, PrivateKeyDer, ServerName};
use tokio::net::lookup_host;
use tokio::net::TcpStream;
@ -238,7 +239,14 @@ mod rustls_connector {
identity: Option<(Vec<CertificateDer<'static>>, PrivateKeyDer<'static>)>,
) -> Result<Self, Error> {
let mut roots = RootCertStore::empty();
for cert in rustls_native_certs::load_native_certs()? {
let CertificateResult {
certs, mut errors, ..
} = rustls_native_certs::load_native_certs();
if let Some(err) = errors.pop() {
return Err(Error::Other(err.into()));
}
for cert in certs {
roots.add(cert).map_err(|err| {
Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>
})?;