在 Windows 上代理后面的货物 ssl 下载错误 [英] cargo ssl download error behind proxy on windows

查看:121
本文介绍了在 Windows 上代理后面的货物 ssl 下载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让货物在经过身份验证的代理后面的 Windows 下开始任何下载.

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

这是我的代理设置:-

C:\Users\ukb99427\Downloads
λ set | grep http
https_proxy=http://user:pass@corporate.proxy:8080
http_proxy=http://user:pass@corporate.proxy:8080

注意 https_proxy 有一个 http 地址.这允许像 git 这样的东西,顺便说一下 rustup-init 和 rustup 可以正常工作.这些输出是

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

但是当运行等效的 cargo install 命令时,我得到以下内容

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

作为测试,我可以运行 curl

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

或者,我尝试将 https_proxy 设置为 https://user:pass@corporate.proxy:8080

Alternatively I try setting the https_proxy to https://user:pass@corporate.proxy:8080

并获得以下内容

λ 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:pass@corporate.proxy: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:pass@corporate.proxy: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:pass@corporate.proxy:8080', libcurl is built without the HTTPS-proxy support.)

参考 curl --version 输出

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 0.24.0-nightly (b83550edc 2017-11-04)

有没有办法让货物使用与 rustup、git 或 curl 相同的设置?其他应用程序可以正常工作,使用 sslverify=false(例如 git),这充其量只是一种解决方法,但会让我在某个地方而不是无处可去.

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.

这一切都在 Windows10 上,在经过身份验证的代理之后.如果没有给出用户/通行证,它(和任何应用程序)会以 http 错误 407 退出,这是有道理的.对于 Windows 应用程序,它们使用运行良好的 IE 设置(对于 Visual Studio Code 或类似应用程序)

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)

我能想到的唯一替代方法是强制一切都只使用 http,但我不知道有什么设置可以让货物发生这种情况.

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?

推荐答案

我为此苦苦挣扎了一段时间,但最终找到了解决方法.我将其发布在这里作为适用于企业防火墙后面的人的可能解决方案.遗憾的是,如果人们不能在工作中轻松安装它,它确实会减少 Rust 的采用.

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.

从 github 下载 crates-io

Download the crates-io from github

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

在 $HOME/.cargo/config 文件中设置注册表

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

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

这会停止通过 libgit-curl 下载注册表,而 libgit-curl 显然不支持 https_proxy.

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

我认为一个长期的解决方案(但我还没有测试过)是使用支持 https 的 libgit-curl 重建货物.

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

这篇关于在 Windows 上代理后面的货物 ssl 下载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆