Skip to content

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

@asfaltboy

Description

@asfaltboy

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<--

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions