Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip behind a proxy with a custom certificate file

Tags:

python

pip

proxy

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]

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.

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

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

like image 654
Quant Avatar asked Jan 27 '16 08:01

Quant


People also ask

How do I get pip to work behind a proxy server?

pip can be configured to connect through a proxy server in various ways: using the --proxy command-line option to specify a proxy in the form scheme://[user:passwd@]proxy.server:port. using proxy in a Configuration Files. by setting the standard environment-variables http_proxy , https_proxy and no_proxy .

Where does pip Look for certificates?

New in version 1.3. By default, pip will perform SSL certificate verification for network connections it makes over HTTPS. These serve to prevent man-in-the-middle attacks against package downloads. This does not use the system certificate store but, instead, uses a bundled CA certificate store from certifi.

How do I install a proxy certificate?

Go to Settings > Personal > Security > Credential storage > Install from storage. 3. Touch the filename of the certificate to install. Only certificates that you haven't already installed are displayed.


1 Answers

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

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

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

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

C:\Users\<username>\pip

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 !

like image 51
NikT Avatar answered Nov 15 '22 09:11

NikT