Forums

SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I code a sign in with twitter the problem is when my application to redirect to the twitter page it gives me an exception. I have all to try as disable_ssl_certificate_validation but nothing works

<class 'httplib2.SSLHandshakeError'> [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Version
web2py     Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python  Python 2.7.6: /usr/local/bin/uwsgi (prefix: /usr)
Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.



Traceback (most recent call last):
  File "/home/devstart16/web2py/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/home/devstart16/web2py/applications/tweetbooki/controllers/default.py", line 89, in <module>
  File "/home/devstart16/web2py/gluon/globals.py", line 417, in <lambda>
    self._caller = lambda f: f()
  File "/home/devstart16/web2py/applications/tweetbooki/controllers/default.py", line 22, in login
    return dict(form=auth())
  File "/home/devstart16/web2py/gluon/tools.py", line 1941, in __call__
    return getattr(self, args[0])()
  File "/home/devstart16/web2py/gluon/tools.py", line 3035, in login
    redirect(cas.login_url(next),
  File "/home/devstart16/web2py/gluon/contrib/login_methods/oauth10a_account.py", line 128, in login_url
    self.__oauth_login(next)
  File "/home/devstart16/web2py/gluon/contrib/login_methods/oauth10a_account.py", line 164, in __oauth_login
    resp, content = client.request(self.token_url, "POST", body=data)
  File "/usr/local/lib/python2.7/dist-packages/oauth2/__init__.py", line 682, in request
    connection_type=connection_type)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1570, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1317, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1252, in _conn_request
    conn.connect()
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1044, in connect
    raise SSLHandshakeError(e)
SSLHandshakeError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

[edit by admin: formatting]

what is the code that causes this error btw?

model side:

class TwitterAccount(OAuthAccount10a):
    global consumer_key
    global consumer_secret
    consumer_key
    consumer_secret 
    AUTH_URL = "http://twitter.com/oauth/authorize"
    TOKEN_URL = "https://twitter.com/oauth/request_token"
    ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token"
    def __init__(self, g=globals()):
        OAuthAccount10a.__init__(self, g,
                              consumer_key,
                              consumer_secret,
                              self.AUTH_URL,
                              self.TOKEN_URL,
                              self.ACCESS_TOKEN_URL)

    def get_user(self):
        if self.accessToken() is not None:
            client = oauth.Client(self.consumer, self.accessToken())
            resp, content = client.request('http://api.twitter.com/1/account/verify_credentials.json')
            if resp['status'] != '200':
                # cannot get user info. should check status
                return None
            u = json.loads(content)
            print(u)
            return dict(username=u['screen_name'], name=u['name'], registration_id=str(u['id']))

twitter_login = TwitterAccount(globals())

controller side

def login():
    if request.vars.bulb == '1':
        auth.settings.login_form=TwitterAccount()
        return dict(form=auth())
    return locals()

[edit by admin: formatting]

I think this is a proxy problem

It shouldn't be a proxy problem -- paid accounts like yours don't need a proxy. Do you have some proxy settings somewhere in your code, perhaps from when you were using a free account?

No I have proxi setting but my code works in locals

Hmm, it looks like httplib2 uses its own certificate root store, and perhaps the one bundled with the version you're using is out of date.

Could you try upgrading httplib2 for your own account by running

pip2.7 install --upgrade --user httplib2

...in a bash console?

it works !!! thank you

Excellent, thanks for confirming!

By the way, you're currently running on our old "classic" system image. We can upgrade you to a new one called "dangermouse" if you like, which will upgrade all of the installed Python modules. The benefit is that you get recent versions of everything -- but, of course, there is a risk that code of yours that is dependent on older modules will break if it's not compatible with the new ones.

Let me know if you'd like us to upgrade you to the new image -- we can always switch you back if it causes problems.