Page MenuHomePhabricator

find a way to automatically install a version of httplib2 that works with MediaWiki
Closed, ResolvedPublic

Description

Author: sumanah

Description:
I'm already logged into meta.wikimedia.org. On metrics.wmflabs.org, if I try to log in by clicking the meta.wikimedia.org logo, the OAuth authorization step goes smoothly.

But on my own local installation of Wikimetrics, in my dev environment running git master, if I try to log in by clicking the meta.wikimedia.org logo, I get an error. (Login via Google goes fine.)

httplib2.SSLHandshakeError

SSLHandshakeError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Traceback (most recent call last)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__

return self.wsgi_app(environ, start_response)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app

response = self.make_response(self.handle_exception(e))

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app

response = self.full_dispatch_request()

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request

 [Display the sourcecode for this frame]  [Open an interactive python shell in this frame] rv = self.handle_user_exception(e)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request

rv = self.dispatch_request()

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request

return self.view_functions[rule.endpoint](**req.view_args)

File "/home/sumanah/test/wikimetrics/wikimetrics/controllers/authentication.py", line 103, in login_meta_mw

redirector = meta_mw.authorize()

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask_oauth.py", line 331, in authorize

token = self.generate_request_token(callback)[0]

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask_oauth.py", line 296, in generate_request_token

self.request_token_params)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/flask_oauth.py", line 108, in request_new_token

body=body, headers=headers)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/httplib2/__init__.py", line 1570, in request

(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/httplib2/__init__.py", line 1317, in _request

(response, content) = self._conn_request(conn, request_uri, method, body, headers)

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/httplib2/__init__.py", line 1252, in _conn_request

conn.connect()

File "/home/sumanah/.virtualenvs/metrics/lib/python2.7/site-packages/httplib2/__init__.py", line 1044, in connect

raise SSLHandshakeError(e)

SSLHandshakeError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Version: unspecified
Severity: normal

Details

Reference
bz60095

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:57 AM
bzimport set Reference to bz60095.
bzimport added a subscriber: Unknown Object (MLST).

bingle-admin wrote:

Prioritization and scheduling of this bug is tracked on Mingle card https://wikimedia.mingle.thoughtworks.com/projects/analytics/cards/cards/1394

You can use the pywikibot/externals/httplib2 fork, we took the certificates from the python-requests library. http://lists.wikimedia.org/pipermail/pywikipedia-l/2013-August/008214.html has some background about why.

Yep, that's what we do. And right now we're doing some weird pip freeeze | grep httplib stuff to figure out which library is installed, uninstall the wrong one and install the pywikibot one. Do you know of a way to just reference the pywikibot one from requirements.txt or setup.py so that pip can find them?

See https://github.com/wikimedia/pywikibot-core/blob/master/setup.py#L68 (line 68) for how to do this from setup.py.

You can also install the ubuntu python-httplib2 package centrally, as that one uses the system certificate store.

Unfortunately it's almost impossible to distinguish this one from a 'pip install'ed one, which carries it's own certificates... (you could check httplib2.CA_CERTS, I guess)

Change 110200 had a related patch set uploaded by Milimetric:
Fix Bug: 60095

https://gerrit.wikimedia.org/r/110200

Thanks a lot for the help Merlijn van Deen. I'm closing this bug for now because the install script seems to handle things a little better than pip, even with the dependency_links set up like you have them. Basically, if httplib2 is already installed, only uninstalling it and checking pip freeze, then installing the correct one is guaranteed to get you set up properly.

If you explicitly require version httplib2-0.8-pywikibot1 (i.e. httplib2==0.8-pywikibot1), any already installed versions should be ignored.

I tried that, and even though I was using --allow-remote httplib2 and --allow-unverified httplib2, pip didn't seem to want to install from that remote. If you'd like to give it a shot, patches are always welcome - I'm kind of a dunce when it comes to this configuration / setup stuff.