【问题标题】:cargo ssl download error behind proxy on windowswindows上代理后面的货物ssl下载错误
【发布时间】:2018-04-23 15:00:44
【问题描述】:

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

这是我的代理设置:-

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 可以正常工作。这些输出是

λ 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 命令时,我得到以下信息

λ 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

λ 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

并得到以下内容

λ 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 输出

λ 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),这充其量是一种解决方法,但可以让我到达某个地方而不是无处可去。

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

我能想到的唯一替代方法是强制所有内容仅使用 http,但我不知道有任何设置可以让货物发生这种情况。

还有什么我可以尝试的想法吗?

【问题讨论】:

    标签: ssl rust rust-cargo


    【解决方案1】:

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

    从 github 下载 crates-io

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

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

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

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

    我认为(但我尚未对此进行测试)的长期解决方案是使用支持 https 的 libgit-curl 重建货物。

    【讨论】:

    • 它对我有帮助,但现在语法更改为: [source.crates-io] replace-with = 'my-awesome-registry' [source.my-awesome-registry] registry = 'file :///C:/Users/someuser/crates.io-index.git'
    【解决方案2】:

    现在(不确定当时是否可行)您可以通过这种方式更新您的 ~/.cargo/config 来解决此问题:

    [http]
    proxy = "http://<user>:<password>@<proxy_url>"
    check-revoke = false
    

    【讨论】:

    • 不,这不起作用,因为 cargo/rustup 似乎不遵守 Windows 上的 SSPI 身份验证。更强大的方法是使用为解决此特定问题而编写的github.com/genotrance/px,它也可以与其他应用程序一起使用
    • @Ronnie 有趣的是,它可以在我的 LAN 中使用 HTTP 代理运行
    • 根据我工作过的不同公司,它似乎有所不同 - 去看看。
    猜你喜欢
    • 1970-01-01
    • 2020-02-08
    • 2019-12-12
    • 2018-10-01
    • 2011-11-23
    • 2011-05-19
    • 1970-01-01
    • 2014-04-10
    • 2021-12-30
    相关资源
    最近更新 更多