Skip to content

Commit

Permalink
feat: make rustls/ring an opt in dep of ewebsock
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jan 2, 2025
1 parent 8914b63 commit 129b619
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ dependencies = [
"futures-util",
"js-sys",
"log",
"rustls",
"tokio",
"tokio-tungstenite",
"tungstenite",
Expand All @@ -1148,7 +1149,6 @@ dependencies = [
"env_logger",
"ewebsock",
"log",
"rustls",
"tokio",
"wasm-bindgen-futures",
"web-sys",
Expand Down
5 changes: 5 additions & 0 deletions ewebsock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ workspace = true
[features]
default = []

## Enables the ring feature on the rustls create to allow connections from native apps to WSS (Not needed if your supply your own CryptoProvider)
rustls_ring = ["dep:rustls", "rustls/ring"]

## Enables tls support
tls = ["tungstenite/rustls-tls-webpki-roots"]

## Opt-in to the tokio executor.
Expand All @@ -47,6 +51,7 @@ log.workspace = true

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustls = { workspace = true, optional = true}
tungstenite.workspace = true

# Optional dependencies for feature "tokio":
Expand Down
3 changes: 1 addition & 2 deletions example_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ tokio = ["ewebsock/tokio", "dep:tokio"]


[dependencies]
ewebsock = { workspace = true, features = ["tls"] }
ewebsock = { workspace = true, features = ["tls", "rustls_ring"] }

eframe.workspace = true
log.workspace = true
env_logger.workspace = true

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustls = { workspace = true, features = ["ring"] }
tokio = { workspace = true, optional = true, features = [
"macros",
"rt-multi-thread",
Expand Down
6 changes: 0 additions & 6 deletions example_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ fn main() -> eframe::Result<()> {
fn main_impl() -> Result<(), eframe::Error> {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

// Setup a CryptoProvider to be able to use wss
match rustls::crypto::ring::default_provider().install_default() {
Ok(()) => {} // Do nothing crypto provider install successful
Err(_) => log::warn!("failed to install CryptoProvider"),
}

let app = example_app::ExampleApp::default();
let native_options = eframe::NativeOptions::default();
eframe::run_native(
Expand Down

0 comments on commit 129b619

Please sign in to comment.