buzz icon indicating copy to clipboard operation
buzz copied to clipboard

buzz CLI: panics with rustls CryptoProvider error

Open dmnyc opened this issue 4 months ago • 2 comments

Posted by Angel, a Buzz agent, on behalf of @dmnyc.

Bug

The buzz agents draft-create (and likely draft-update) subcommands panic with a rustls CryptoProvider error. All other buzz CLI subcommands (messages, channels, canvas, etc.) connect and work fine — only the agents code path is affected.

Reproduce

buzz agents draft-create --channel <any-channel-uuid> --display-name "Test" --system-prompt "Test"

Error

thread 'main' panicked at rustls-0.23.42/src/crypto/mod.rs:249:14:

Could not automatically determine the process-level CryptoProvider from Rustls crate features.
Call CryptoProvider::install_default() before this point to select a provider manually, or make sure exactly one of the 'aws-lc-rs' and 'ring' features is enabled.

Backtrace

   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: rustls::client::client_conn::ClientConfig::builder_with_protocol_versions
   4: tokio_tungstenite::tls::encryption::rustls::wrap_stream::{{closure}}
   5: buzz_ws_client::connection::publish_event::{{closure}}::{{closure}}
   6: buzz_cli::client::BuzzClient::publish_ephemeral_event::{{closure}}
   7: buzz_cli::commands::agents::dispatch::{{closure}}
   8: buzz_cli::run::{{closure}}
   9: tokio::runtime::park::CachedParkThread::block_on
  10: tokio::runtime::context::runtime::enter_runtime
  11: tokio::runtime::runtime::Runtime::block_on
  12: buzz::main

Analysis

The panic occurs through the tokio-tungstenite rustls TLS path used by buzz_ws_client::connection::publish_event. Other commands (e.g. buzz messages get, buzz messages send) succeed over the same relay, so they must use a different code path that either installs a CryptoProvider or avoids this rustls entry point.

The agents dispatch path calls BuzzClient::publish_ephemeral_event → buzz_ws_client::connection::publish_event → tokio_tungstenite::tls::encryption::rustls::wrap_stream, which calls rustls::client::ClientConfig::builder_with_protocol_versions() without a CryptoProvider installed.

Likely fix

Either:

  1. Call CryptoProvider::install_default() (e.g. aws_lc_rs::AwsLcRs::default_provider().install_default()) early in buzz_cli::run or at the start of the agents dispatch path, or
  2. Ensure exactly one of the aws-lc-rs / ring features is enabled on the rustls dependency so the default provider is auto-detected.

The same install should cover all subcommands so they share one consistent TLS initialization path.

Environment

  • buzz binary: shipped with Buzz.app (/Applications/Buzz.app/Contents/MacOS/buzz)
  • Architecture: Mach-O 64-bit arm64
  • OS: macOS 26.4.1 (Build 25E253)
  • rustls version: 0.23.42

dmnyc avatar Jul 24 '26 02:07 dmnyc

This looks fixed on main as of df0a0861 (#2590, merged 2026-07-23).

buzz_cli::run_from_args now installs ring as the process-level rustls CryptoProvider at CLI entry, before anything can reach ClientConfig::builder() — see crates/buzz-cli/src/lib.rs:38. The in-code comment names this exact code path: the WSS publish in publish_ephemeral_event used by agents draft-create / agents draft-update (and users set-presence), which matches frames 4–6 of your backtrace.

Root cause per that fix: the release workflow builds all binaries in one cargo invocation, which unifies features across the workspace and enables both ring (via buzz-acp/buzz-dev-mcp) and aws-lc-rs (via reqwest's rustls feature). With both enabled, rustls can't auto-select a provider and panics on first use of that builder — which is why only the ephemeral-publish subcommands tripped it while everything else worked.

A rebuild from current main should clear the panic; a binary from the next release cut will carry the fix as well.

webdevtodayjason avatar Jul 24 '26 11:07 webdevtodayjason

Another data point: this is not limited to the agents code path. buzz-pairing-cli (the buzz-pair NIP-AB interop tool) panics identically the moment it opens the pairing WebSocket:

$ cargo build --release -p buzz-pairing-cli
$ ./target/release/buzz-pair source --relay wss://<relay> --nsec nsec1...
QR URI (contains session secret — do not share beyond the target device):
nostrpair://...&v=1
Waiting for target to scan QR code...

thread 'main' panicked at rustls-0.23.42/src/crypto/mod.rs:249:14:
Could not automatically determine the process-level CryptoProvider from Rustls crate features.

Note the URI is printed before the connection is attempted, so the tool emits a pairing code and then dies — the session is never live, which makes the failure look like a relay problem rather than a client crash.

Root cause

The workspace pulls rustls transitively with TLS enabled but no provider selected:

# Cargo.toml
tokio-tungstenite = { version = "0.29", features = ["rustls-tls-webpki-roots"] }

rustls-tls-webpki-roots turns on rustls without enabling ring or aws-lc-rs, and nothing in the crate calls CryptoProvider::install_default(). In a full-workspace build another crate happens to enable a provider and feature unification masks it, which is why this only reproduces for some binaries / some build invocations.

Worth calling out because it makes the bug look intermittent: building both binaries in one invocation (cargo build -p buzz-pairing-cli -p buzz-cli) does not fix it — with both ring and aws-lc-rs then enabled, the provider is ambiguous rather than absent, and rustls panics with the same message.

Fix

Either call CryptoProvider::install_default() at startup in each binary, or pin exactly one provider. The latter was a one-line change:

# crates/buzz-pairing-cli/Cargo.toml
rustls = { version = "0.23", default-features = false, features = ["ring"] }

After that the pairing session connects and completes a full source↔target handshake (SAS + encrypted payload transfer) against a self-hosted relay. Happy to open a PR if a maintainer indicates which of the two approaches is preferred.

frischeDaten avatar Aug 08 '26 17:08 frischeDaten