Use rustls-native-certs as the root store

This commit is contained in:
Dirkjan Ochtman 2023-07-31 16:44:03 +02:00
parent 1eff89bd32
commit 454e879d08
2 changed files with 10 additions and 10 deletions

View File

@ -9,18 +9,18 @@ repository = "https://github.com/InstantDomain/instant-epp"
[features]
default = ["rustls"]
rustls = ["tokio-rustls"]
rustls = ["tokio-rustls", "rustls-native-certs"]
[dependencies]
async-trait = "0.1.52"
celes = "2.1"
chrono = { version = "0.4.23", features = ["serde"] }
instant-xml = { version = "0.3", features = ["chrono"] }
rustls-native-certs = { version = "0.6.3", optional = true }
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["io-util", "net", "time"] }
tokio-rustls = { version = "0.24", optional = true }
tracing = "0.1.29"
webpki-roots = "0.24"
[dev-dependencies]
regex = "1.5"

View File

@ -221,7 +221,7 @@ mod rustls_connector {
use tokio::net::lookup_host;
use tokio::net::TcpStream;
use tokio_rustls::client::TlsStream;
use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName};
use tokio_rustls::rustls::{ClientConfig, RootCertStore, ServerName};
use tokio_rustls::TlsConnector;
use tracing::info;
@ -241,13 +241,13 @@ mod rustls_connector {
identity: Option<(Vec<Certificate>, PrivateKey)>,
) -> Result<Self, Error> {
let mut roots = RootCertStore::empty();
roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
}));
for cert in rustls_native_certs::load_native_certs()? {
roots
.add(&tokio_rustls::rustls::Certificate(cert.0))
.map_err(|err| {
Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>
})?;
}
let builder = ClientConfig::builder()
.with_safe_defaults()