Why I receive CERTIFICATE_VERIFY_FAILED from google adwords api?

Chameleon picture Chameleon · Jun 8, 2015 · Viewed 11k times · Source

Why google adwords api stops on call this link:

https://adwords.google.com/api/adwords/mcm/v201502/CustomerService?wsdl

With this error - should I load some certificate before and how?

urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>

Using Python 2.7.10.

Full source code: create_adwords_client_without_yaml.py

Full error code:

Traceback (most recent call last):
  File "C:/Users/Crezary Wagner/PycharmProjects/learn-adwords/src/examples/create_adwords_client_without_yaml.py", line 56, in <module>
    CLIENT_CUSTOMER_ID)
  File "C:/Users/Crezary Wagner/PycharmProjects/learn-adwords/src/examples/create_adwords_client_without_yaml.py", line 50, in main
    customer = adwords_client.GetService('CustomerService').get()
  File "C:\root\Python27\lib\site-packages\googleads\adwords.py", line 256, in GetService
    proxy=proxy_option, cache=self.cache, timeout=3600)
  File "C:\root\Python27\lib\site-packages\suds\client.py", line 115, in __init__
    self.wsdl = reader.open(url)
  File "C:\root\Python27\lib\site-packages\suds\reader.py", line 150, in open
    d = self.fn(url, self.options)
  File "C:\root\Python27\lib\site-packages\suds\wsdl.py", line 136, in __init__
    d = reader.open(url)
  File "C:\root\Python27\lib\site-packages\suds\reader.py", line 74, in open
    d = self.download(url)
  File "C:\root\Python27\lib\site-packages\suds\reader.py", line 92, in download
    fp = self.options.transport.open(Request(url))
  File "C:\root\Python27\lib\site-packages\suds\transport\https.py", line 62, in open
    return HttpTransport.open(self, request)
  File "C:\root\Python27\lib\site-packages\suds\transport\http.py", line 67, in open
    return self.u2open(u2request)
  File "C:\root\Python27\lib\site-packages\suds\transport\http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "C:\root\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\root\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\root\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\root\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\root\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>

Answer

Mansoorulhaq Mansoor picture Mansoorulhaq Mansoor · Jul 25, 2015

Python uses certificates from 'system ssl certificate store' to certify https connection, if there is not any appropriate ssl cert in the store error occurs like this. Download ssl certificate (Open your https link in browser and click lock icon in address bar > More Information > View Certificate > Details > Export) and install it on your system as stated this link http://windows.microsoft.com/en-us/windows/import-export-certificates-private-keys#1TC=windows-7