diff --git a/Cargo.lock b/Cargo.lock index dfff0d30..28738c67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,6 +404,7 @@ dependencies = [ "rand 0.8.5", "rust-crypto", "rustls", + "rustls-native-certs", "sha2", "thiserror", "tokio 1.39.2", @@ -1119,6 +1120,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64", + "rustls-pki-types", +] + [[package]] name = "rustls-pki-types" version = "1.8.0" diff --git a/Cargo.toml b/Cargo.toml index b4799936..c791c402 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,5 +27,6 @@ openssl = "0.10.66" tokio-rustls = "0.26.0" webpki = "0.22.4" webpki-roots = "0.26.3" +rustls-native-certs = "0.8.0" [lib] doctest = false diff --git a/src/client/tls_connection.rs b/src/client/tls_connection.rs index c5843320..bf698df9 100644 --- a/src/client/tls_connection.rs +++ b/src/client/tls_connection.rs @@ -54,7 +54,11 @@ impl ClientConnection for ClientTLSConnection { /// creates socket tcp, sends query and receive response async fn send(self, dns_query: DnsMessage) -> Result, ClientError> { // async fn send(self, dns_query: DnsMessage) -> Result<(Vec, IpAddr), ClientError> { - + let root_store = RootCertStore::empty(); + let mut roots = rustls::RootCertStore::empty(); + for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") { + roots.add(cert).unwrap(); + } let conn_timeout: Duration = self.get_timeout(); let bytes: Vec = dns_query.to_bytes(); let server_addr:SocketAddr = SocketAddr::new(self.get_server_addr(), 53);