From ae2f929bb8d0235ff74fec74ad77053b52f353af Mon Sep 17 00:00:00 2001 From: Diane Huxley Date: Mon, 23 Sep 2024 13:06:24 -0700 Subject: [PATCH] Remove webpki to fix FOSSA license error --- crates/web5/Cargo.toml | 2 +- crates/web5/src/http.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/web5/Cargo.toml b/crates/web5/Cargo.toml index 15e1c59c..b4468953 100644 --- a/crates/web5/Cargo.toml +++ b/crates/web5/Cargo.toml @@ -30,7 +30,7 @@ zbase32 = "0.1.2" lazy_static = "1.5.0" flate2 = "1.0.33" rustls = { version = "0.23.13", default-features = false, features = ["std", "tls12"] } -webpki-roots = "0.26.5" +rustls-native-certs = "0.8.0" [dev-dependencies] mockito = "1.5.0" diff --git a/crates/web5/src/http.rs b/crates/web5/src/http.rs index 83ad06a4..ab7c627b 100644 --- a/crates/web5/src/http.rs +++ b/crates/web5/src/http.rs @@ -1,13 +1,13 @@ use crate::errors::{Result, Web5Error}; use rustls::pki_types::ServerName; use rustls::{ClientConfig, ClientConnection, RootCertStore, StreamOwned}; +use rustls_native_certs::load_native_certs; use serde::de::DeserializeOwned; use std::collections::HashMap; use std::io::{Read, Write}; use std::net::TcpStream; use std::sync::Arc; use url::Url; -use webpki_roots::TLS_SERVER_ROOTS; pub struct HttpResponse { pub status_code: u16, @@ -57,8 +57,11 @@ fn transmit(destination: &Destination, request: &[u8]) -> Result> { if destination.schema == "https" { // HTTPS connection - // Create a RootCertStore and load the root certificates from webpki-roots - let root_store = RootCertStore::from_iter(TLS_SERVER_ROOTS.iter().cloned()); + // Create a RootCertStore and load the root certificates from rustls_native_certs + let mut root_store = RootCertStore::empty(); + for cert in load_native_certs().unwrap() { + root_store.add(cert).unwrap(); + } // Build the ClientConfig using the root certificates and disabling client auth let config = ClientConfig::builder()