Configure the server trust anchors for tokio-rustls

pull/60/head
Constantin Nickel 4 years ago committed by Sebastian Dröge
parent e4eb921df6
commit a9fd92529e
  1. 6
      Cargo.toml
  2. 5
      src/tokio.rs

@ -20,7 +20,7 @@ gio-runtime = ["gio", "glib"]
async-tls = ["real-async-tls"] async-tls = ["real-async-tls"]
async-native-tls = ["async-std-runtime", "real-async-native-tls"] async-native-tls = ["async-std-runtime", "real-async-native-tls"]
tokio-native-tls = ["tokio-runtime", "real-tokio-native-tls", "real-native-tls", "tungstenite/tls"] tokio-native-tls = ["tokio-runtime", "real-tokio-native-tls", "real-native-tls", "tungstenite/tls"]
tokio-rustls = ["tokio-runtime", "real-tokio-rustls"] tokio-rustls = ["tokio-runtime", "real-tokio-rustls", "webpki-roots"]
tokio-openssl = ["tokio-runtime", "real-tokio-openssl", "openssl"] tokio-openssl = ["tokio-runtime", "real-tokio-openssl", "openssl"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
@ -79,6 +79,10 @@ optional = true
version = "^0.14" version = "^0.14"
package = "tokio-rustls" package = "tokio-rustls"
[dependencies.webpki-roots]
optional = true
version = "0.20"
[dependencies.gio] [dependencies.gio]
optional = true optional = true
version = "0.9" version = "0.9"

@ -50,7 +50,10 @@ pub(crate) mod tokio_tls {
let connector = if let Some(connector) = connector { let connector = if let Some(connector) = connector {
connector connector
} else { } else {
let config = ClientConfig::new(); let mut config = ClientConfig::new();
config
.root_store
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
AsyncTlsConnector::from(std::sync::Arc::new(config)) AsyncTlsConnector::from(std::sync::Arc::new(config))
}; };
let domain = DNSNameRef::try_from_ascii_str(&domain) let domain = DNSNameRef::try_from_ascii_str(&domain)

Loading…
Cancel
Save