Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cargo ssl download error behind proxy on windows

I cannot get cargo to commence any downloads under windows behind an authenticated proxy.

Here are my proxy settings:-

C:\Users\ukb99427\Downloads
λ set | grep http
https_proxy=http://user:[email protected]:8080
http_proxy=http://user:[email protected]:8080

Note the https_proxy has a http address. This allows something like git and incidentally rustup-init and rustup to work fine. Output from those are

λ rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: latest update on 2017-11-10, rust version 1.23.0-nightly (d6b06c63a 2017-11-09)
info: downloading component 'rustc'
 33.4 MiB /  33.4 MiB (100 %)   2.7 MiB/s ETA:   0 s

But when running an equivalent cargo install command I get the following

λ cargo install libc
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [12/-2] [56] Failure when receiving data from the peer
warning: spurious network error (1 tries remaining): [12/-2] [56] Failure when receiving data from the peer

As a test I can run curl

λ curl --insecure https://github.com/rust-lang/crates.io-index -o registry.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  785k    0  785k    0     0   389k      0 --:--:--  0:00:02 --:--:--  393k

Alternatively I try setting the https_proxy to https://user:[email protected]:8080

and get the following

λ cargo install libc
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [12/-2] [4] A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. (Unsupported proxy 'https://user:[email protected]:8080', libcurl is built without the HTTPS-proxy support.)
warning: spurious network error (1 tries remaining): [12/-2] [4] A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. (Unsupported proxy 'https://user:[email protected]:8080', libcurl is built without the HTTPS-proxy support.)
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [12/-2] [4] A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. (Unsupported proxy 'https://user:[email protected]:8080', libcurl is built without the HTTPS-proxy support.)

For reference curl --version outputs

λ curl --version
curl 7.53.0 (x86_64-w64-mingw32) libcurl/7.53.0 OpenSSL/1.0.2k zlib/1.2.11 libssh2/1.8.0 nghttp2/1.19.0 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: IPv6 Largefile SSPI Kerberos SPNEGO NTLM **SSL** libz TLS-SRP HTTP2 HTTPS-proxy Metalink

Cargo version

λ cargo version
cargo 0.24.0-nightly (b83550edc 2017-11-04)

Is there any way to get cargo to use the same settings as rustup,git or curl? Other apps work ok, with sslverify=false (such as git), which is at best a work around, but would get me somewhere as opposed to nowhere.

This is all on Windows10, behind a authenticated proxy. With no user/pass given, it (and any application) exits with http error 407 which makes sense. For windows apps, they use the IE settings which work fine (for applications like Visual Studio Code or anything similar)

The only alternative I can think of is to force everything to use http only, but I don't know of any settings to make that happen for cargo.

Any thoughts on what else I can try?

like image 293
Delta_Fore Avatar asked Nov 10 '17 11:11

Delta_Fore


2 Answers

I struggled with this a while but finally figured out a work around. I post this here as a possible solution for those behind corporate firewalls. It does, sadly, reduce adoption of rust if people can't install it easily at work.

Download the crates-io from github

git clone --bare https://github.com/rust-lang/crates.io-index.git

In $HOME/.cargo/config file set the registry like

[registry]
index = "file:///C:/Users/someuser/crates.io-index.git"

This stops the registry download via libgit-curl which apparently doesn't support https_proxy.

A longer term solution I think (but I've not tested this yet), is to rebuild cargo with libgit-curl supporting https.

like image 176
Delta_Fore Avatar answered Nov 13 '22 02:11

Delta_Fore


Now (not sure if it was possible at the time) you have another possible solution for this issue, by updating your ~/.cargo/config this way :

[http]
proxy = "http://<user>:<password>@<proxy_url>"
check-revoke = false
like image 27
Adonis Avatar answered Nov 13 '22 02:11

Adonis