Skip to content

Commit

Permalink
Check version of cryptography module
Browse files Browse the repository at this point in the history
We have had multiple issues with Ubuntu 16.04 using an outdated version
of the Python cryptography module that causes strange SSL behavior.
Example for this is not being able to connect to SSL sites.

This commit introduces a check on Kodi startup so the user is aware
of the issue.

See also:
pyca/pyopenssl#542 (comment)
https://forum.kodi.tv/showthread.php?tid=335786
  • Loading branch information
pkerling committed Oct 28, 2018
1 parent 3c08e74 commit 263e792
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
14 changes: 14 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,17 @@ msgstr ""
msgctxt "#32035"
msgid "It is recommended that you to upgrade to a newer version."
msgstr ""

#empty strings from id 32036 to 32039

msgctxt "#32040"
msgid "Your version %s of the Python cryptography module is too old. You need at least version 1.7."
msgstr ""

msgctxt "#32041"
msgid "Please upgrade your operating system."
msgstr ""

msgctxt "#32042"
msgid "For more information, see https://kodi.wiki/view/Linux"
msgstr ""
23 changes: 21 additions & 2 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

import platform
import xbmc
import xbmcgui
import lib.common
from lib.common import log, dialog_yesno
from lib.common import log, dialog_yesno, localise
from lib.common import upgrade_message as _upgrademessage
from lib.common import upgrade_message2 as _upgrademessage2

Expand Down Expand Up @@ -102,9 +103,27 @@ def _versionchecklinux(packages):
log("Unsupported platform %s" %platform.dist()[0])
sys.exit(0)


# Python cryptography < 1.7 (still shipped with Ubuntu 16.04) has issues with
# pyOpenSSL integration, leading to all sorts of weird bugs - check here to save
# on some troubleshooting. This check may be removed in the future (when switching
# to Python3?)
# See /~https://github.com/pyca/pyopenssl/issues/542
def _checkcryptography():
ver = None
try:
import cryptography
ver = cryptography.__version__
except:
# If the module is not found - no problem
return

ver_parts = list(map(int, ver.split('.')))
if len(ver_parts) < 2 or ver_parts[0] < 1 or (ver_parts[0] == 1 and ver_parts[1] < 7):
log('Python cryptography module version %s is too old, at least version 1.7 needed' % ver)
xbmcgui.Dialog().ok(ADDONNAME, localise(32040) % ver, localise(32041), localise(32042))

if (__name__ == "__main__"):
_checkcryptography()
if ADDON.getSetting("versioncheck_enable") == "false":
log("Disabled")
else:
Expand Down

0 comments on commit 263e792

Please sign in to comment.