Unable to make connection to Portal using the ArcGIS Hub API for Python (SSL Error)

6007
2
Jump to solution
07-01-2020 05:55 AM
EricAnderson_DHS
Occasional Contributor

Hello all,

Trying out the new ArcGIS Hub API for Python, which is built off the ArcGIS API for Python. 

I am attempting to make a connection to our Portal using the following code:

from arcgishub.hub import Hub
dev = Hub("PORTALURL","USERNAME","PASSWORD")

When I do, I get the following error:

_SSLError: Please set verify_cert=False due to encountered SSL error: HTTPSConnectionPool(host='HOSTURL', port=443): Max retries exceeded with url: /WEBADAPTOR/sharing/rest/info?f=json (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (ssl.c:852)'),))

If I try to add "verify_cert=False" to the connection, like so:

dev = Hub("PORTALURL","USERNAME","PASSWORD",verify_cert=False)

I now get the error:

TypeError: init() got an unexpected keyword argument 'verify_cert'

I tried adding our Portal cert to the Windows' Trusted Root certs (mmc.exe), and also tried running the script internally and hitting the FQDN as opposed to the public URL - both with the same result. Also tried Rohit's suggestion here using import ssl and the ssl command: Cannot access my portal usinhg arcgis python api 

So in summary, it seems like the Hub API does not support verify_cert like the ArcGIS API does when making a connection to your Portal. My question is two fold then, is there a way to resolve this SSL error in our Portal, or is there a way to bypass the SSL verification with the Hub API. 

Thank you,

Eric

Portal for ArcGISArcGIS API for Python ArcGIS Hub

0 Kudos
1 Solution

Accepted Solutions
EricAnderson_DHS
Occasional Contributor

Here is the workaround for anyone who might come across this issue, worked for me: https://github.com/Esri/hub-py/issues/95

View solution in original post

0 Kudos
2 Replies
MehdiPira1
Esri Contributor

Hi Eric A‌,

This has been a bug in ArcGIS API for Python in Portal for a long time.

It's been logged in Esri Support as "The Verify_cert parameter is not honored when connecting to Portal for ArcGIS using ArcGIS Python API."

BUG-000118241: The Verify_cert parameter is not honored when connec.. 

EricAnderson_DHS
Occasional Contributor

Here is the workaround for anyone who might come across this issue, worked for me: https://github.com/Esri/hub-py/issues/95

0 Kudos