Installing conda packages when not being logged in to my organizational network fails when using corporate's ssl-certificate

Viewed 28

In order to be able to install conda and pip packages from within my organizational network I configured conda to use my corporate's .pem file using:

conda config --set ssl_verify <pathToMyFile>.pem

Everything works fine with downloading and installing packages but as soon as I am not logged in to the network (e.g. because I am working from home) I can't install any packages anymore. It seems that I have to be logged in to my corporate's network when using the respective .pem file.

Specifically I am getting the following error:

Collecting package metadata (repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/conda-forge/linux-64/repodata.json>

This problem has already been discussed here where user @payala summed up the problem in the comment section:

Yes, but then this will only work while you are within your organization's network. If you are using a notebook and you exit the network, it will not work. What can be done that supports adding this certificate in addition to the ones already used by conda? – payala

One solution would be to follow the suggestion from user @user6020015 who says:

if you leave your organization's network, you can just comment out that line in .condarc with a # and uncomment when you return.

However, this seems very tedious to me, because I would have to comment and uncomment this line of code several times per week. Is there a solution to solve this?

1 Answers

I'd probably add some shorthand commands to the shell (e.g., ~/.bashrc), like...

function conda_work() { 
  conda config --set ssl_verify <pathToMyFile>.pem
}

function conda_play() {
  conda config --remove-key ssl_verify
}

to quickly toggle the setting.

Related