Skip to content

Commit

Permalink
Fix creation of the rustls client
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc authored and arqunis committed Oct 17, 2020
1 parent bba7d55 commit 35e2a40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ features = ["tokio-runtime"]
optional = true
version = "0.9.2"

[dependencies.rustls]
default-features = false
version = "0.18"

[dependencies.webpki-roots]
version = "0.19"

[dependencies.typemap_rev]
optional = true
version = "0.1.3"
Expand Down
6 changes: 5 additions & 1 deletion src/internal/ws_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ impl StdError for RustlsError {
#[cfg(all(feature = "rustls_backend", not(feature = "native_tls_backend")))]
#[instrument]
pub(crate) async fn create_rustls_client(url: Url) -> Result<WsStream> {
let (stream, _) = async_tungstenite::tokio::connect_async_with_config::<Url>(
let mut config = rustls::ClientConfig::new();
config.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
let connector = std::sync::Arc::new(config).into();
let (stream, _) = async_tungstenite::tokio::connect_async_with_tls_connector_and_config::<Url>(
url,
Some(connector),
Some(async_tungstenite::tungstenite::protocol::WebSocketConfig {
max_message_size: None,
max_frame_size: None,
Expand Down

0 comments on commit 35e2a40

Please sign in to comment.