Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point #336

Closed
t348575 opened this issue Jun 4, 2024 · 6 comments

Comments

@t348575
Copy link

t348575 commented Jun 4, 2024

After upgrading tokio-tungstenite to 0.23 from 0.22, I get the below panic when connecting to a secured websocket endpoint.

My Cargo.toml entry: tokio-tungstenite = { version = "0.23", features = ["rustls-tls-webpki-roots"] }

this might have something to do with it?

The panic:

thread 'tokio-runtime-worker' panicked at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.9/src/crypto/mod.rs:259:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_display
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/panicking.rs:262:5
   3: core::option::expect_failed
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/option.rs:1997:5
   4: core::option::Option<T>::expect
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/option.rs:898:21
   5: rustls::crypto::CryptoProvider::get_default_or_install_from_crate_features
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.9/src/crypto/mod.rs:258:24
   6: rustls::client::client_conn::ClientConfig::builder_with_protocol_versions
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.9/src/client/client_conn.rs:284:13
   7: rustls::client::client_conn::ClientConfig::builder
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.9/src/client/client_conn.rs:261:9
   8: tokio_tungstenite::tls::encryption::rustls::wrap_stream::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-tungstenite-0.23.0/src/tls.rs:110:33
   9: tokio_tungstenite::tls::client_async_tls_with_config::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-tungstenite-0.23.0/src/tls.rs:211:83
  10: tokio_tungstenite::connect::connect::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-tungstenite-0.23.0/src/connect.rs:79:82
  11: tokio_tungstenite::connect::connect_async_with_config::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-tungstenite-0.23.0/src/connect.rs:34:74
  12: tokio_tungstenite::connect::connect_async::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-tungstenite-0.23.0/src/connect.rs:19:53
  13: common::twitch::ws::WsPool::connect_twitch_ws::{{closure}}
             at /home/joefe/repos/twitch-points-miner/common/src/twitch/ws.rs:396:10
  14: common::twitch::ws::WsPool::add_connection::{{closure}}
             at /home/joefe/repos/twitch-points-miner/common/src/twitch/ws.rs:303:14
  15: common::twitch::ws::WsPool::retry_add_connection::{{closure}}
             at /home/joefe/repos/twitch-points-miner/common/src/twitch/ws.rs:287:41
  16: common::twitch::ws::WsPool::run::{{closure}}
             at /home/joefe/repos/twitch-points-miner/common/src/twitch/ws.rs:103:45
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/future/future.rs:123:9
  18: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/core.rs:328:17
  19: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/loom/std/unsafe_cell.rs:16:9
  20: tokio::runtime::task::core::Core<T,S>::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/core.rs:317:13
  21: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:485:19
  22: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/panic/unwind_safe.rs:272:9
  23: std::panicking::try::do_call
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:559:40
  24: __rust_try
  25: std::panicking::try
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:523:19
  26: std::panic::catch_unwind
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panic.rs:149:14
  27: tokio::runtime::task::harness::poll_future
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:473:18
  28: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:208:27
  29: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:153:15
  30: tokio::runtime::task::raw::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/raw.rs:271:5
  31: tokio::runtime::task::raw::RawTask::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/raw.rs:201:18
  32: tokio::runtime::task::LocalNotified<S>::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/mod.rs:427:9
  33: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:585:13
  34: tokio::runtime::coop::with_budget
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/coop.rs:107:5
  35: tokio::runtime::coop::budget
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/coop.rs:73:5
  36: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:584:9
  37: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:535:24
  38: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:500:21
  39: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context/scoped.rs:40:9
  40: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context.rs:180:26
  41: std::thread::local::LocalKey<T>::try_with
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/thread/local.rs:286:12
  42: std::thread::local::LocalKey<T>::with
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/thread/local.rs:262:9
  43: tokio::runtime::context::set_scheduler
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context.rs:180:9
  44: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:495:9
  45: tokio::runtime::context::runtime::enter_runtime
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context/runtime.rs:65:16
  46: tokio::runtime::scheduler::multi_thread::worker::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:487:5
  47: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/multi_thread/worker.rs:455:45
  48: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/blocking/task.rs:42:21
  49: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/core.rs:328:17
  50: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/loom/std/unsafe_cell.rs:16:9
  51: tokio::runtime::task::core::Core<T,S>::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/core.rs:317:13
  52: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:485:19
  53: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/panic/unwind_safe.rs:272:9
  54: std::panicking::try::do_call
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:559:40
  55: __rust_try
  56: std::panicking::try
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:523:19
  57: std::panic::catch_unwind
             at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panic.rs:149:14
  58: tokio::runtime::task::harness::poll_future
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:473:18
  59: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:208:27
  60: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/harness.rs:153:15
  61: tokio::runtime::task::raw::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/raw.rs:271:5
  62: tokio::runtime::task::raw::RawTask::poll
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/raw.rs:201:18
  63: tokio::runtime::task::UnownedTask<S>::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/task/mod.rs:464:9
  64: tokio::runtime::blocking::pool::Task::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/blocking/pool.rs:159:9
  65: tokio::runtime::blocking::pool::Inner::run
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/blocking/pool.rs:513:17
  66: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/joefe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/blocking/pool.rs:471:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@cernicc
Copy link

cernicc commented Jun 5, 2024

It might also be this?

@t348575
Copy link
Author

t348575 commented Jun 5, 2024

Yep, missed that.

@t348575 t348575 closed this as completed Jun 5, 2024
@Zercerium
Copy link

Hi, will this change be reverted? currently I have to add rustls by myself as a dependency and enable the aws_lc_rs feature if I want to use rustls with this create.

@agalakhov
Copy link
Member

You can always call CryptoProvider::install_default() manually. It should be done once at the very beginning.

@Zercerium
Copy link

thanks a lot for the reply. For clarification, in this case I would also have to include rustls to call CryptoProvider::install_default() cause it is not exported by tokio_tungstenite and I have to provide my own CryptoProvider cause CryptoProvider::install_default() needs a self reference.

@jiangxiaoqiang
Copy link

add this to fixed this issue:

rustls::crypto::ring::default_provider().install_default().expect("Failed to install rustls crypto provider");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants