I'm trying to access my portal using ArcGIS Python API
code below(portalAdminUser is the build-in user)
import arcgis
from arcgis.gis import GIS
portalUrl = ""
portalAdminUser = ""
portalAdminUserPassword = ""
arcgis = GIS(portalUrl, portalAdminUser, portalAdminUserPassword)
But I'm getting error message "URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>"
It works fine when I use portalpy.
anyone has idea what the issue is?
Thanks
Solved! Go to Solution.
Are you on Windows or Linux?
What version of Python are you using?
Are you using a self signed certificate?
The following code would turn off SSL certification entirely - can you check if it resolves this problem? However, please note that this isn't a safe thing to do as it turns off SSL certification verficiation for the python process and isn't recommended for production.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
gis = ...
I'm very new to this, but in some of the samples (and in the demos) the have this comment:
Create a connection to the portal. In this case, we will exercise the verify_cert option to not validate the SSL certificate (True by default).
with this:
gis = GIS("portal url", "username", "password", verify_cert=False)
(bold added)
Might try it for testing at least.
I did try verify_cert=False option and get the same message.
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
But portalpy works for me.
Are you on Windows or Linux?
What version of Python are you using?
Are you using a self signed certificate?
The following code would turn off SSL certification entirely - can you check if it resolves this problem? However, please note that this isn't a safe thing to do as it turns off SSL certification verficiation for the python process and isn't recommended for production.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
gis = ...
Hi Singh,
I’m running ArcGIS Python API 1.0.1 on windows. My portal has CA signed ssl cert. When I use portpy it works. But not ArcGIS Python API.
Both portalpy and python api has similar connection syntax to connect to the portal. Not sure why arcgis python api got ssl cert error.
Xiaoyi
It works for my scripts. (generate token). I understand it an work around, not a real solution.
verify_cert=False worked for me. Thank you!
Hi Xiaoyi,
My workaround to this problem is to use the ':6443' portal url rather the one behind webadaptor with verify_cert=False. Using the ':6443' url will bypass the CA check.
Cheers
S.
Do you mean 7443(Portal) or 6443(Server) here? I'm having the same issue...thanks!