Avoid enabling multiple rustls backends by accident

For this, we had to:

- Make the choice(s) of backend explicit in tokio-xmpp features
- Avoid picking a backend through transitive dependencies in xmpp
  (reqwest->hyper->rustls).

In addition, we choose the default rustls backend by default and adapt
the examples so that they can cope with either situation.
This commit is contained in:
Jonas Schäfer 2025-05-10 09:54:01 +02:00
commit 4e9e18444c
11 changed files with 134 additions and 15 deletions

View file

@ -4,6 +4,11 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#[cfg(all(
feature = "starttls-rust",
any(feature = "starttls-rust-aws_lc_rs", feature = "starttls-rust-ring")
))]
use xmpp::tokio_xmpp::rustls;
use xmpp::{
jid::BareJid,
muc::room::{JoinRoomSettings, RoomMessageSettings},
@ -19,6 +24,20 @@ use std::str::FromStr;
async fn main() -> Result<(), Option<()>> {
env_logger::init();
#[cfg(all(feature = "starttls-rust", feature = "starttls-rust-aws_lc_rs"))]
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("failed to install rustls crypto provider");
#[cfg(all(
feature = "starttls-rust",
feature = "starttls-rust-ring",
not(feature = "starttls-rust-aws_lc_rs")
))]
rustls::crypto::ring::default_provider()
.install_default()
.expect("failed to install rustls crypto provider");
let args: Vec<String> = args().collect();
if args.len() < 3 {
println!("Usage: {} <jid> <password> [ROOM...]", args[0]);