Forums

SSL: WRONG_VERSION_NUMBER arcgis.com

Hi there,

I am encountering an error when attempting to connect to ArcGIS Online. The domain "arcgis.com" has been whitelisted and I am using the pythonanywhere proxy to connect. I have tried using ssl_cerify=False in the connection but no further success.

Here is the connection string:

gis = GIS(proxy_host="proxy.server", proxy_port=3128, verfiy_ssl=False, url="https://worldearth.maps.arcgis.com", username='myusername', password='mypassword')

The error message returned is as follows:

 During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/__init__.py", line 452, in __init__
    raise e
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/__init__.py", line 399, in __init__
    self._portal = _portalpy.Portal(
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_portalpy.py", line 201, in __init__
    self.get_properties(True)
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_portalpy.py", line 1220, in get_properties
    raise e
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_portalpy.py", line 1200, in get_properties
    resp = self.con.post(path, self._postdata(), ssl=True)
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_con/_connection.py", line 933, in post
    elif token_as_header == False and self.token is not None:  # as ?token=
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1391, in token
    self._token = self._enterprise_token()
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1535, in _enterprise_token
    res = self.post(path=self._token_url, params=postdata, add_token=False)
  File "/home/worldearth/.local/lib/python3.8/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1010, in post
    raise requests.exceptions.SSLError(
requests.exceptions.SSLError: Please set verify_cert=False due to encountered SSL error: HTTPSConnectionPool(host='worldearth.maps.arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/generateT
oken (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)')))

I have tested my code on a local environment and it works without issue, I have also tried Python 3.9, 3.8 and 3.6 versions with the arcgis module. All return the same error message.

Any help or support on this would be much appreciated

Thanks!

worldearth.maps.arcgis.com is not whitelisted as .arcgis.com is a wildcard for one level of subdomains only.

As an experiment, could you try to upgrade and run it on paid account (you can always downgrade in the first 30 days and get a refund from us).

Hi there,

Thanks very much for getting back to me. I changed the host in the connection to http://arcgis.com and this also gave the same error message.

gis = GIS(proxy_host="proxy.server", proxy_port=3128, verfiy_ssl=False, url="https://arcgis.com", username='myusername', password='mypassword')

To validate that this connection string is valid, I tested on a local python environment and it connected successfully.

Thanks

On the paid account, it should not be using the proxy, but connecting directly.

Thanks for the reply, yes the paid account works fine so I guess the problem lies with the proxy. Are there any plans to investigate this proxy issue further? I would stay with the paid account however it does not seem to allow frequencies of greater than hourly to execute scheduled tasks?

Many thanks

I don't think it's a problem with the proxy per se; the site you're trying to connect to was not whitelisted -- "*.arcgis.comwas whitelisted, but becauseworldearth.maps.arcgis.comhas two names in front of the.arcgis.com` , that wildcard does not include that domain.

I've added worldearth.maps.arcgis.com, explicitly to the whitelist, so it would be interesting to see if the code with the proxy server now works.

Regarding more-than-hourly scheduled tasks -- you can just schedule the same script multiple times, so if (say) you want it to run twice an hour, once at three past and once at 33 past, you'd just add two lines to the tasks table, one for each run.

Thank you for the quick reply as always. I originally tested connecting to "worldearth.maps.arcgis.com" and later "arcgis.com" only, however nth produced the same SSL error (as per original post). I have just tried "worldearth.maps.arcgis.com" again following your updates to the whitelisting, however the same error occurs. Thank you for arranging this for me to test however. Connections to both "worldearth.maps.arcgis.com" and "arcgis.com" work without issue when using the paid account when the proxy server is removed from the connection string.

Thanks you for the advice on the scheduled task frequency, much appreciated.

That is strange! I did just spot that there appears to be a typo in your code, though -- verfiy_ssl=False should be verify_ssl=False. Does changing that have any useful effect?

Thanks that was a good spot, but unfortunately the same error remains:

Please set verify_cert=False due to encountered SSL error: HTTPSConnectionPool(host='worldearth.maps.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:1129)')))

Using the following connection string:

gis = GIS(proxy_host="proxy.server", proxy_port=3128, verify_cert=False, url="https://worldearth.maps.arcgis.com", username='myusername', password='mypassword')

I also tried again using only the "arcgis.com" top level domain, and using "verify_ssl" and "verify_cert"

Could you try to run it without proxy_host and proxy_port?

It works fine when I remove the proxy details, for example:

gis = GIS(verify_cert=False, url="https://worldearth.maps.arcgis.com", username='myusername', password='mypassword')

or

gis = GIS(url="https://arcgis.com", username='myusername', password='mypassword')

Ok, so at least we know that it works with a paid account.

I'm running into this same issue and can't solve it. Have either of you made any progress on this issue yet?

It looks like worldearth was able to have that working -- see two posts above.

Yes that's correct, via a paid account, it has been working without issue

Thanks for both of your responses. I was able to get this working with a paid account as well. It seems like this is supposed to be possible with a free account as well though through the proxy. Does this mean the official solution now is that in order to work with arcgis.com services, it is only possible through the paid account? Just double checking.

It does look like that may not work through the proxy, so a paid account would be necessary.

Same error returns for endpoints within azure.cognitiveservices.vision.computervision

How are you trying to access those endpoints?