Skip to content

Commit 709f266

Browse files
mattssegrandizzy
andauthored
fix: force install default crypto provider (#10327)
* fix: force install default crypto provider * Fix tests and cargo deny --------- Co-authored-by: grandizzy <[email protected]>
1 parent 23b1cbd commit 709f266

File tree

12 files changed

+32
-3
lines changed

12 files changed

+32
-3
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ thiserror = "2"
259259

260260
# misc
261261
auto_impl = "1"
262+
aws-config = { version = "1", default-features = true }
263+
aws-sdk-kms = { version = "1", default-features = false }
262264
bytes = "1.8"
263265
walkdir = "2"
264266
prettyplease = "0.2"
@@ -293,6 +295,7 @@ reqwest = { version = "0.12", default-features = false, features = [
293295
"rustls-tls",
294296
"rustls-tls-native-roots",
295297
] }
298+
rustls = "0.23"
296299
semver = "1"
297300
serde = { version = "1.0", features = ["derive"] }
298301
serde_json = { version = "1.0", features = ["arbitrary_precision"] }

crates/anvil/src/args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn run() -> Result<()> {
1616

1717
/// Setup the exception handler and other utilities.
1818
pub fn setup() -> Result<()> {
19+
utils::install_crypto_provider();
1920
handler::install();
2021
utils::load_dotenv();
2122
utils::enable_paint();

crates/cast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ serde_json.workspace = true
6161
serde.workspace = true
6262

6363
# aws-kms
64-
aws-sdk-kms = { version = "1", default-features = false, optional = true }
64+
aws-sdk-kms = { workspace = true, default-features = false, optional = true }
6565

6666
# bin
6767
foundry-cli.workspace = true

crates/cast/src/args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub fn run() -> Result<()> {
3838

3939
/// Setup the global logger and other utilities.
4040
pub fn setup() -> Result<()> {
41+
utils::install_crypto_provider();
4142
handler::install();
4243
utils::load_dotenv();
4344
utils::subscriber();

crates/chisel/src/args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn run() -> Result<()> {
3535

3636
/// Setup the global logger and other utilities.
3737
pub fn setup() -> Result<()> {
38+
utils::install_crypto_provider();
3839
handler::install();
3940
utils::subscriber();
4041
utils::load_dotenv();

crates/cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ tokio = { workspace = true, features = ["macros"] }
4747
tracing-subscriber = { workspace = true, features = ["registry", "env-filter"] }
4848
tracing.workspace = true
4949
yansi.workspace = true
50+
rustls = { workspace = true, features = ["ring"] }
5051

5152
tracing-tracy = { version = "0.11", optional = true }
5253

crates/cli/src/utils/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,23 @@ pub fn enable_paint() {
205205
yansi::whenever(yansi::Condition::cached(enable));
206206
}
207207

208+
/// This force installs the default crypto provider.
209+
///
210+
/// This is necessary in case there are more than one available backends enabled in rustls (ring,
211+
/// aws-lc-rs).
212+
///
213+
/// This should be called high in the main fn.
214+
///
215+
/// See also:
216+
/// <https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455100010>
217+
/// <https://github.com/awslabs/aws-sdk-rust/discussions/1257>
218+
pub fn install_crypto_provider() {
219+
// https://github.com/snapview/tokio-tungstenite/issues/353
220+
rustls::crypto::ring::default_provider()
221+
.install_default()
222+
.expect("Failed to install default rustls crypto provider");
223+
}
224+
208225
/// Useful extensions to [`std::process::Command`].
209226
pub trait CommandUtils {
210227
/// Returns the command's output if execution is successful, otherwise, throws an error.

crates/forge/src/args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn run() -> Result<()> {
2121

2222
/// Setup the global logger and other utilities.
2323
pub fn setup() -> Result<()> {
24+
utils::install_crypto_provider();
2425
handler::install();
2526
utils::load_dotenv();
2627
utils::subscriber();

crates/forge/tests/it/test_helpers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use alloy_chains::NamedChain;
44
use alloy_primitives::U256;
55
use forge::{revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder};
6+
use foundry_cli::utils::install_crypto_provider;
67
use foundry_compilers::{
78
artifacts::{EvmVersion, Libraries, Settings},
89
compilers::multi::MultiCompiler,
@@ -172,6 +173,7 @@ impl ForgeTestData {
172173
///
173174
/// Uses [get_compiled] to lazily compile the project.
174175
pub fn new(profile: ForgeTestProfile) -> Self {
176+
install_crypto_provider();
175177
init_tracing();
176178
let config = Arc::new(profile.config());
177179
let mut project = config.project().unwrap();

crates/wallets/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ alloy-dyn-abi.workspace = true
2727

2828
# aws-kms
2929
alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true }
30-
aws-config = { version = "1", default-features = true, optional = true }
31-
aws-sdk-kms = { version = "1", default-features = false, optional = true }
30+
aws-config = { workspace = true, default-features = true, optional = true }
31+
aws-sdk-kms = { workspace = true, default-features = false, optional = true }
3232

3333
# gcp-kms
3434
alloy-signer-gcp = { workspace = true, features = ["eip712"], optional = true }

deny.toml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ allow = [
5656
"MPL-2.0",
5757
"CDDL-1.0",
5858
"Zlib",
59+
"OpenSSL",
5960
]
6061

6162
# Allow 1 or more licenses on a per-crate basis, so that particular licenses

0 commit comments

Comments
 (0)