|
|
@ -71,12 +71,21 @@ mod encryption { |
|
|
|
Mode::Plain => Ok(StreamSwitcher::Plain(stream)), |
|
|
|
Mode::Plain => Ok(StreamSwitcher::Plain(stream)), |
|
|
|
Mode::Tls => { |
|
|
|
Mode::Tls => { |
|
|
|
let config = { |
|
|
|
let config = { |
|
|
|
|
|
|
|
#[allow(unused_mut)] |
|
|
|
let mut config = ClientConfig::new(); |
|
|
|
let mut config = ClientConfig::new(); |
|
|
|
config.root_store = |
|
|
|
#[cfg(feature = "rustls-native-roots")] |
|
|
|
rustls_native_certs::load_native_certs().map_err(|(_, err)| err)?; |
|
|
|
{ |
|
|
|
|
|
|
|
config.root_store = |
|
|
|
|
|
|
|
rustls_native_certs::load_native_certs().map_err(|(_, err)| err)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(feature = "rustls-webpki-roots")] |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
config.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Arc::new(config) |
|
|
|
Arc::new(config) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let domain = DNSNameRef::try_from_ascii_str(domain).map_err(TlsError::Dns)?; |
|
|
|
let domain = DNSNameRef::try_from_ascii_str(domain).map_err(TlsError::Dns)?; |
|
|
|
let client = ClientSession::new(&config, domain); |
|
|
|
let client = ClientSession::new(&config, domain); |
|
|
|
let stream = StreamOwned::new(client, stream); |
|
|
|
let stream = StreamOwned::new(client, stream); |
|
|
|