milesrichardson / ParsePy

A relatively up-to-date fork of ParsePy, the Python wrapper for the Parse.com API. Originally maintained by @dgrtwo
MIT License
515 stars 184 forks source link

SSL: CERTIFICATE_VERIFY_FAILED #175

Open tanyanghan opened 5 years ago

tanyanghan commented 5 years ago

Python: 2.7.15 MacOS Mojave 10.14.1

If the parse endpoint is a https://, I'm getting a:

File "/Library/Python/2.7/lib/python/site-packages/parse_rest/connection.py", line 140, in execute
    response = urlopen(request, timeout=CONNECTION_TIMEOUT)
... <other stuff> ...
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)>

I added an argument cafile to parse_rest/connection.py line 140 pointing to my certifi pem file (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/certifi/cacert.pem) which fixed my problem:

urllib2.urlopen(url[, data[, timeout[, cafile[, capath[, cadefault[, context]]]]])

( https://docs.python.org/2/library/urllib2.html#urllib2.urlopen )

Is there a more correct way to do this?