Open tpanza opened 3 years ago
This is also still happening with mamba 0.16, libcurl 7.79.1, and conda/4.10.3 requests/2.25.1 CPython/3.9.7 Windows/10 Windows/10.0.19042
Can you show me the command line arguments you'd use with curl
to download a file from this channel?
And then it would be cool to use curl ... --libcurl=test.c
and then send me the contents of test.c
From Windows Git Bash, using curl 7.61.1 (x86_64-w64-mingw32) libcurl/7.61.1 OpenSSL/1.0.2p (WinSSL) zlib/1.2.11 libidn2/2.0.5 nghttp2/1.33.0
:
curl -O --cacert /c/Users/mywindowsusername/.ssl/certs/mycompany-ca-bundle.pem https://MY_ARTIFACTORY_USERNAME:MY_ARTIFACTORY_API_TOKEN@artifactory.web.mycompany.com/artifactory/Conda-Forge/channeldata.json
From Windows Command Prompt, using curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
:
curl -O --cacert C:\Users\mywindowsusername\.ssl\certs\mycompany-ca-bundle.pem https://MY_ARTIFACTORY_USERNAME:MY_ARTIFACTORY_API_TOKEN@artifactory.web.mycompany.com/artifactory/Conda-Forge/channeldata.json
Here is the contents of test.c
, generated with the Windows Command Prompt:
/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_URL, "https://MY_ARTIFACTORY_USERNAME:MY_ARTIFACTORY_API_TOKEN@artifactory.web.mycompany.com/artifactory/Conda-Forge/channeldata.json");
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.55.1");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_CAINFO, "C:\\Users\\mywindowsusername\\.ssl\\certs\\mycompany-ca-bundle.pem");
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_INTERLEAVEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer
*/
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
return (int)ret;
}
/**** End of sample code ****/
Here are the contents of test.c
, using the curl
from Windows Git Bash:
/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_URL, "https://MY_ARTIFACTORY_USERNAME:MY_ARTIFACTORY_API_TOKEN@artifactory.web.mycompany.com/artifactory/Conda-Forge/channeldata.json");
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.61.1");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
curl_easy_setopt(hnd, CURLOPT_CAINFO, "C:/Users/mywindowsusername/.ssl/certs/mycompany-ca-bundle.pem");
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_INTERLEAVEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer
*/
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
return (int)ret;
}
/**** End of sample code ****/
Are you properly setting the certificates in your .condarc
file?
Please show the contents of conda info
.
Ah sorry, you posted them in the first comment! I am having a look.
I think what's happening is that we somehow accidentally strip the auth information when parsing the channels.
You could probably work around it by putting the full url in the channels entry ... I'll have to take a look at the channel parsing to fix this.
@tpanza You can work around this by creating a .netrc
file and sticking it in your %UserProfile%
directory. The contents of that file should be:
machine artifactory.web.mycompany.com
login MY_ARTIFACTORY_USERNAME
password MY_ARTIFACTORY_API_TOKEN
You'll also need to create a new env var called HOME that points at your profile (the need to do this was fixed in libcurl 7.84, but that hasn't released to conda-forge yet). You can easily do this in a cmd shell like:
setx HOME %UserProfile%
or in powershell like
setx HOME $ENV:UserProfile
In either case, restart your terminal, and then your mamba install commands will auth correctly to your artifactory instance.
This works for conda, too, not just mamba. So you'll be able to remove the basic auth from the URLs in your condarc file completely.
Thanks, @FaustinCarter . Confirmed that the .netrc
method does indeed work. (It also lets me remove the auth credentials that were embedded within my pip configuration.)
Thanks, @FaustinCarter . Confirmed that the
.netrc
method does indeed work. (It also lets me remove the auth credentials that were embedded within my pip configuration.)
Glad to help out. By the way, the curl update finally dropped to conda-forge, so setting %HOME%
is no longer necessary.
We switched from basic auth in the channel URLs awhile ago because of a bug (now patched) in conda-build where it wasn’t stripping the creds from the channel URLs before including the build channels in any package we made. This was effectively leaking our API keys all over the place every time we built and distributed a package.
Sounds like mamba doesn’t have that problem since it apparently strips auth before even sending a request to the server 🤣
To reach any conda channels, I must go through a private, corporate on-prem Artifactory proxy to reach them. This Artifactory server requires a username and API token login.
conda
works fine in this setup, using this~/.condarc
file:However, when I try to do any install-related commands with
mamba
0.15.3, I get HTTP 403 errors. Below is a verbose trace output: