foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.19k stars 1.7k forks source link

Installing solc behind a proxy fails #3057

Open davebryson opened 2 years ago

davebryson commented 2 years ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

0.2.0

What command(s) is the bug in?

forge build

Operating System

macOS (Apple Silicon)

Describe the bug

Installing solc on a new project fails with invalid peer certificate: UnknownIssuer. I'm pretty sure this is due to the corporate MITM proxy I'm behind. Is there another way to manually install solc as a work around?

mattsse commented 2 years ago

hmm

this may be related https://www.reddit.com/r/rust/comments/vy5bof/rust_with_reqwest_behind_a_local_http_proxy_burp/

we use https://github.com/roynalnaruto/svm-rs/ to install svm

which is its own cli tool

pre-built apple silicon solc builds are fetched from https://github.com/roynalnaruto/solc-builds/tree/fc7263e8b571b6a4c754d443fa4b7b4236b4735f/macosx/aarch64

we check if they're installed like this

~/.svm/0.8.16/solc-0.8.16

~/.svm/0.8.16/solc-0.8.16 --version

solc, the solidity compiler commandline interface
Version: 0.8.16+commit.07a7930e.Darwin.appleclang
davebryson commented 2 years ago

@mattsse Thanks for the response. Adding the feature native-tls to the reqwest dependency in svm solved the problem. I used svm separately to install a solc version. Forge then worked perfectly

mattsse commented 2 years ago

I see, will check if there's a workaround for rustls as well

jamesmorgan commented 1 year ago

We are also hitting this issue - any ideas on a work around? I assume this is due to corporate machine setup

mattsse commented 1 year ago

this seems to be a common issue: https://github.com/denoland/deno/issues/10312

https://github.com/rustls/rustls/issues/731

does installing via svm directly work?

could you share the error output so we can track down where exactly this is thrown?

davebryson commented 1 year ago

@mattsse @jamesmorgan I solved the issue by making one small change to SVM and rebuilding locally. Specifically, I changed this line: https://github.com/roynalnaruto/svm-rs/blob/master/Cargo.toml#L41 to:

reqwest = { version = "^0.11.7", default-features = false, features = ["json", "native-tls"] }

and installed SVM separately. Foundary worked without issue after that - even updates.

I no longer have details about the specific error output. But essentially is was related to an SSL CERT error when installing foundary rs, a common issue with MITM corporate proxies

callum-elvidge commented 1 year ago

I got around this issue by using @davebryson method whilst installing solc however this same error is thrown when trying to deploy a contract using a script and there seems to be no obvious workaround. Will there be native tls support anytime soon?

forge script script/Deploy.s.sol --rpc-url $SEPOLIA_RPC_URL --broadcast --verify -vvvv
Error: 
error sending request for url (https://eth-sepolia.g.alchemy.com/v2/{API_KEY): error trying to connect: invalid peer certificate contents: invalid peer certificate: UnknownIssuer

Context:
- Error #0: error trying to connect: invalid peer certificate contents: invalid peer certificate: UnknownIssuer
- Error #1: invalid peer certificate contents: invalid peer certificate: UnknownIssuer