Cannot access my portal usinhg arcgis python api

9250
8
Jump to solution
03-16-2017 06:52 AM
XiaoyiZhang1
Emerging Contributor

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

0 Kudos
1 Solution

Accepted Solutions
RohitSingh2
Esri Contributor

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 = ...

View solution in original post

8 Replies
RebeccaStrauch__GISP
MVP Emeritus

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.

XiaoyiZhang1
Emerging Contributor

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.

0 Kudos
RohitSingh2
Esri Contributor

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 = ...
XiaoyiZhang1
Emerging Contributor

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

0 Kudos
WenfengLi
Occasional Contributor

It works for my scripts. (generate token). I understand it an work around, not a real solution.

0 Kudos
by Anonymous User
Not applicable

verify_cert=False worked for me. Thank you!

SpencerHan1
Emerging Contributor

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.

MichaelAugust
Frequent Contributor

Do you mean 7443(Portal) or 6443(Server) here? I'm having the same issue...thanks!

0 Kudos