2
Traceback (most recent call last):
  File "C:\Python27\Scripts\Vehicle Model.py", line 12, in <module>
    response = requests.get(URL_PATTERN1)
  File "C:\Python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

I get the above error after compiling my code. I am currently using Edmunds API to extract specific items from their API. I don't know why I don't get this error message when I compile on other computers.

Then when I add:

context = ssl._create_unverified_context()
urllib2.urlopen("https://no-valid-cert", context=context)

I get the following error:

Traceback (most recent call last):
  File "C:\Python27\Scripts\Vehicle Model.py", line 10, in <module>
    urllib2.urlopen("https://no-valid-cert", context=context)
  File "C:\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Euxitheos
  • 325
  • 4
  • 15
  • Try this: http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error – Quinn Feb 09 '16 at 18:26
  • When I add the line: context = ssl._create_unverified_context() urllib2.urlopen("https://no-valid-cert", context=context) Then I get another error: URLError: – Euxitheos Feb 09 '16 at 19:10

1 Answers1

0

You should first verify that everything is set up correctly with curl. Here are the steps I would use:

curl --version
curl -v https://api.edmunds.com/
# this latter should verify that SSL and libcurl are working properly on the computer 

If both of those work, then requests should also work. If you want to use requests without verifying SSL, you can use the verify parameter to get.

session.get('https://api.edmunds.com/', verify=False)
2ps
  • 15,099
  • 2
  • 27
  • 47