Skip to content

Commit

Permalink
fix(rust): pull the crypto provider instantiation closer to the start…
Browse files Browse the repository at this point in the history
… of the command line
  • Loading branch information
etorreborre authored and SanjoDeundiak committed Nov 12, 2024
1 parent d859300 commit 0d88c20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 0 additions & 12 deletions implementations/rust/ockam/ockam_command/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ impl OckamCommand {
return Ok(());
}

// Setup the default rustls crypto provider, this is a required step when
// multiple backends ring/aws-lc are pulled in directly, or indirectly.
#[cfg(feature = "aws-lc")]
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("Failed to install aws-lc crypto provider");

#[cfg(all(feature = "rust-crypto", not(feature = "aws-lc")))]
rustls::crypto::ring::default_provider()
.install_default()
.expect("Failed to install ring crypto provider");

// Sets a hook using our own Error Report Handler.
// This allows us to customize how we format the error messages and their content.
let _hook_result = miette::set_hook(Box::new(|_| Box::new(ErrorReportHandler::new())));
Expand Down
12 changes: 12 additions & 0 deletions implementations/rust/ockam/ockam_command/src/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ use ockam_api::output::Output;
/// - Display the help if the arguments cannot be parsed and store a user journey error
///
pub fn run() -> miette::Result<()> {
// Setup the default rustls crypto provider, this is a required step when
// multiple backends ring/aws-lc are pulled in directly, or indirectly.
#[cfg(feature = "aws-lc")]
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("Failed to install aws-lc crypto provider");

#[cfg(all(feature = "rust-crypto", not(feature = "aws-lc")))]
rustls::crypto::ring::default_provider()
.install_default()
.expect("Failed to install ring crypto provider");

let input = std::env::args()
.map(replace_hyphen_with_stdin)
.collect::<Vec<_>>();
Expand Down

0 comments on commit 0d88c20

Please sign in to comment.