在具有自定义证书文件的代理后面插入 [英] Pip behind a proxy with a custom certificate file

查看:79
本文介绍了在具有自定义证书文件的代理后面插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pip的代理设置可以通过--proxy命令行选项或在全局配置文件中指定(在Unix中为$HOME/.config/pip/pip.conf,在OS X中为$HOME/Library/Application Support/pip/pip.conf,在Windows中为%APPDATA%\pip\pip.ini).

Proxy settings for pip can be specified via the --proxy command line option or in the global configuration file (that is $HOME/.config/pip/pip.conf in Unix, $HOME/Library/Application Support/pip/pip.conf in OS X, %APPDATA%\pip\pip.ini in Windows).

[global]
proxy = [proxy server url]

但是,尽管可以使用--cert命令行选项传递自定义根证书文件,但似乎没有办法在配置文件中指定自定义根证书.

However, while a custom root certificate file can be passed with the --cert command line option, there does not seem to be a way to specify a custom root certificate in the configuration file.

与命令行选项不同,似乎没有考虑在上述全局配置中指定cert = [path to cert file].

Specifying cert = [path to cert file] in the above global configuration does not seem to be taken into account, unlike the command line option.

我们如何全局设置pip以使用某个证书文件?

How can we globally set up pip to use a certain certificate file?

推荐答案

我们在代理后面,并且也需要证书.确保证书文件位于cmd和pip(Windows)可以访问的位置.我的证书叫做b.pem

we're behind a proxy and need the cert too. Make sure the cert file is in a place that cmd and pip (windows) would have access to. My cert is just called b.pem

我创建了一个名为(尚不存在)的文件夹:

I created the folder (which didn't exist already) called:

C:\Users\<username>\appdata\Roaming\pip

,然后将文件pip.ini添加到该文件夹​​.然后在pip.ini

and added the file pip.ini to it to that folder. then in pip.ini

[global]
cert = C:\users\<username>\b.pem

我还测试了将pip.ini文件添加到:

I also just tested adding the the pip.ini file to:

C:\Users\<username>\pip

顺便说一句,

是一个已经创建的文件夹-这也可以工作.可能想尝试一下,看看哪个可行.另外,听起来有些愚蠢,但请确保您在pip.ini中的路径正确.我第一次做错字了,这让我发疯了一点哈哈.祝你好运!

which, by the way, was a folder that was already created -- and this works too. Might want to give both a shot and see which works. Also, sounds dumb but make sure your path in pip.ini is correct. I had a typo the first time i did this and it drove me insane for a bit haha. good luck !

这篇关于在具有自定义证书文件的代理后面插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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