Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to send requests to coursera.org over ssl #13

Open
asfaltboy opened this issue Mar 29, 2015 · 2 comments
Open

Failure to send requests to coursera.org over ssl #13

asfaltboy opened this issue Mar 29, 2015 · 2 comments

Comments

@asfaltboy
Copy link
Contributor

This seems to be a new issue for me (not sure exactly from when since I wasn't using the addon for a while), and occurs on both my OSX and RaspberryPi2 builds.

My search for the culprit lead me to an unpatched version of underlying ssl library (openssl/libressl depending on platform); specifically the missing SNI declaration feature, and it might have only surfaced now if the coursera team decided to patch their server only now (to mitigate MIM attacks).

Although I have not tried to use urllib/2 I tend to believe that the issue would occur there as well since they use the same underlying ssl libraries.

There is a way to use different ssl/crypto libs with requests/urllib3, but this means we'd have to compile the dependencies (with gcc) for each platform we want to support and attach the pre-built libs with the addon. I don't like this way, so I've opened an issue with Kodi team to support any of the above.

Here is a log excerpt from my OSX machine for future reference:

08:04:31 T:4712275968   ERROR: .../Kodi/addons/script.module.requests/lib/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
                                              InsecurePlatformWarning
08:04:31 T:4712275968   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
 - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'requests.exceptions.SSLError'> 
Error Contents: [Errno 1] _ssl.c:480: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
Traceback (most recent call last):
  File ".../Kodi/addons/plugin.video.coursera/addon.py", line 293, in <module>
    plugin.run()
  File ".../Kodi/addons/script.module.xbmcswift2/lib/xbmcswift2/plugin.py", line 332, in run
    items = self._dispatch(self.request.path)
  File ".../Kodi/addons/script.module.xbmcswift2/lib/xbmcswift2/plugin.py", line 306, in _dispatch
    listitems = view_func(**items)
  File ".../Kodi/addons/plugin.video.coursera/addon.py", line 33, in index
    classes = loadClasses(username, password)
  File ".../Kodi/addons/script.module.xbmcswift2/lib/xbmcswift2/xbmcmixin.py", line 81, in wrapper
    result = function(*args, **kwargs)
  File ".../Kodi/addons/plugin.video.coursera/course_utils.py", line 60, in loadClasses
    classes = getClasses(cookies=cookies_raw, verify=True)
  File ".../Kodi/addons/plugin.video.coursera/course_utils.py", line 176, in getClasses
    data = get_page(COURSES_LIST_URL, json=True, **kwargs)
  File ".../Kodi/addons/plugin.video.coursera/course_utils.py", line 78, in get_page
    res = s.get(href, **kwargs)
  File ".../Kodi/addons/script.module.requests/lib/requests/sessions.py", line 476, in get
    return self.request('GET', url, **kwargs)
  File ".../Kodi/addons/script.module.requests/lib/requests/sessions.py", line 464, in request
    resp = self.send(prep, **send_kwargs)
  File ".../Kodi/addons/script.module.requests/lib/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File ".../Kodi/addons/script.module.requests/lib/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [Errno 1] _ssl.c:480: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
-->End of Python script error report<--
@asfaltboy
Copy link
Contributor Author

Seems another scraper of coursera have experienced the same issue - coursera-dl/coursera-dl#330.

So in case anyone has the issue in an environment under his/her control it's possible to resolve the issue by installing a couple dependencies (details are in the kodi trac issue or the coursera-dl issue)

@asfaltboy asfaltboy changed the title Failure to send requests pages from coursera.org over ssl Failure to send requests pages to coursera.org over ssl Apr 14, 2015
@asfaltboy asfaltboy changed the title Failure to send requests pages to coursera.org over ssl Failure to send requests to coursera.org over ssl Apr 14, 2015
@MasterOfPuppets
Copy link

Same fail here with ubuntu 14.04

@asfaltboy asfaltboy mentioned this issue Jun 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants