Fix native-certs and add to test matrix

Close #239
This commit is contained in:
Martin Algesten
2021-11-26 14:20:39 +01:00
parent 69ad3aabb0
commit a6d1750f14
3 changed files with 8 additions and 6 deletions

View File

@@ -335,7 +335,7 @@ pub(crate) fn connect_https(unit: &Unit, hostname: &str) -> Result<Stream, Error
static TLS_CONF: Lazy<Arc<rustls::ClientConfig>> = Lazy::new(|| {
let mut root_store = rustls::RootCertStore::empty();
#[cfg(not(feature = "native-tls"))]
#[cfg(not(feature = "native-certs"))]
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
@@ -343,10 +343,11 @@ pub(crate) fn connect_https(unit: &Unit, hostname: &str) -> Result<Stream, Error
ta.name_constraints,
)
}));
#[cfg(feature = "native-tls")]
root_store.add_server_trust_anchors(
rustls_native_certs::load_native_certs().expect("Could not load platform certs"),
);
#[cfg(feature = "native-certs")]
for cert in rustls_native_certs::load_native_certs().expect("Could not load platform certs")
{
root_store.add(&rustls::Certificate(cert.0)).unwrap();
}
let config = rustls::ClientConfig::builder()
.with_safe_defaults()