Should I turn off certificate verification and ignore warnings when calling Apple Search API from Python 3.4 and urllib3.request?
What I tried:
I first found a problem when I made a call using urllib.request from a virtual environment (with Python Tools for Visual Studio 2013) e.g.
r = urllib.request.urlopen('https://itunes.apple.com/lookup?id=429313263')
Raises this error:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
Strangely, when I made the same call from my normal Python 3.4 environment (i.e. not in a virtual environment), I received no errors.
However, I want to use a virtual env, so I thought I would try using urllib3.request. When I require certificate verification, it also fails:
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) r = http.request('GET', 'https://itunes.apple.com/lookup?id=429313263')
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
Does this simply mean that there is something wrong with the certificate on Apple's server?
I changed the call to not require certification:
http = urllib3.PoolManager(cert_reqs='CERT_NONE',assert_hostname=False)
which unsurprisingly gave the warning:
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
I disabled warnings (obviously not normally advisable):
urllib3.disable_warnings()