arcgis-python-api
arcgis-python-api copied to clipboard
HTTPS requests through HTTP Proxy Fail - Error SSL: WRONG_VERSION_NUMBER
When specifying a proxy host, there is no setting to specify http vs https. Our proxy uses http for both http and https requests. It appears that this worked up until a certain version of urllib3. It looks like urllib3 was more forgiving with misconfigurations in the past and is stricter now.
So, this is sort of a an enhancement and sort of a bug. In previous conda environments that were deployed with ArcGIS Pro, the following would work:
gis=GIS(url, username, password, proxy_host="my.proxy.url.com", proxy_port=80)
With newer versions of urllib3 that are installed with the Pro conda environment, this no longer works if your https proxy needs to be configured to "http://" not "https://". It now throws the following error:
SSLError: Please set verify_cert=False due to encountered SSL error: HTTPSConnectionPool(host='arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/generateToken (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)')))
Found in 1.8.5. I downloaded just the arcgis package for the latest version. I haven't tried running it, but the proxy code looks the same.
Solution: Need to be able to pass in a proxy dict
{
"http": "http://my.proxy.url.com:80",
"https": "http://my.proxy.url.com:80",
}
or some other way other than just passing in the domain name. I tried setting the following:
os.environ['https_proxy'] = r"http://my.proxy.url.com:80"
It did not work. Even if this had worked, it would be a workaround. You really need to be able to set the proxy urls manually instead of letting the api build it for you.
For my use, I just changed the dict that the api was building in arcgis\gis\_impl\_con\_connection.py to use http for both, but there really needs to be a way to use the package without modification.