Cargo on Windows behind a corporate proxy

2019-06-18 07:44发布

问题:

I think this is a very common issue among those who want to use Cargo with Windows at work; I have seen multiple GitHub issues and forum posts related to it, but none of the answers solved my problems.

Whenever I try to build some code pointing to a crates.io crate, I get the following error:

 Downloading <package>
error: unable to get packages from source

Caused by:
  failed to download package <package> from <package address>

Caused by:
  SSL connect error

What can I do to fix this? I know that Cargo can use the settings at .cargo/config and that the proxy details can be included there, but it doesn't work for me, with or without specifying the path for the certificate (I used the one distributed with curl), like below:

[http]
proxy = "http://user:password@proxy-address.xyz:port"
cainfo = "cert.pem"

[https]
proxy = "https://user:password@proxy-address.xyz:port"
cainfo = "cert.pem"

The proxy specified in the config file works for any other purpose.

I'm using Windows 7 64bit, Rust 1.11 GNU and Cargo bundled with it. How can I get this working? Currently I have to resort to downloading crate sources manually from their repositories and specifying paths = [...] for each of them in the Cargo config file.

回答1:

It appears that this is no longer an issue as of cargo 0.13 bundled with Rust 1.13 stable - I no longer need to manually download packages and put them in paths in cargo's config file.