Skip to content

Commit

Permalink
fix(jetsocat): preemptively install crypto provider on start
Browse files Browse the repository at this point in the history
This is typically not required because we only enable the ring backend,
which is then automatically installed by rustls when
`ClientConfig::builder` is called later down the road.
However, it may be the case that during development the aws-lc-rs feature
of rustls is enabled, causing rustls to crash the process requesting
to install a default crypto provider.
To smoothen the developer experience, we attempt to install the ring
crypto provider just before executing the command action.
Our CI is already ensuring that we are not shipping both crypto backends
by mistake.
  • Loading branch information
CBenoit committed Nov 12, 2024
1 parent b54a666 commit da68b6f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jetsocat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ fn generate_usage() -> String {
}

pub fn run<F: Future<Output = anyhow::Result<()>>>(f: F) -> anyhow::Result<()> {
// Install the default crypto provider when rustls is used.
#[cfg(feature = "rustls")]
if rustls::crypto::ring::default_provider().install_default().is_err() {
let installed_provider = rustls::crypto::CryptoProvider::get_default();
debug!(?installed_provider, "default crypto provider is already installed");
}

let rt = runtime::Builder::new_multi_thread()
.enable_all()
.build()
Expand Down

0 comments on commit da68b6f

Please sign in to comment.