From 3eaf62de5b32b8bd27de9a8f4ad6e44ed151e585 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 1 Mar 2016 22:16:53 +0530 Subject: [PATCH] Yet another fix for python ssl distro compatibility Apparently CentOS 7 just decided to backport the SSL patches from 2.7.9 to 2.7.5! Sigh. I have no idea if this change will cause installation to stop working on old Debian/Ubuntu. I love linux. Fixes #1551800 [Automatic Linux install fails with SSL error](https://bugs.launchpad.net/calibre/+bug/1551800) --- setup/linux-installer.py | 2 +- src/calibre/utils/https.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/setup/linux-installer.py b/setup/linux-installer.py index cf0f264352..8fbc30a0cc 100644 --- a/setup/linux-installer.py +++ b/setup/linux-installer.py @@ -20,7 +20,7 @@ if enc.lower() == 'ascii': enc = 'utf-8' calibre_version = signature = None urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1) -has_ssl_verify = hasattr(ssl, 'PROTOCOL_TLSv1_2') and sys.version_info[:3] > (2, 7, 8) +has_ssl_verify = hasattr(ssl, 'create_default_context') if py3: unicode = str diff --git a/src/calibre/utils/https.py b/src/calibre/utils/https.py index b64cec2532..2a1fd5a7fc 100644 --- a/src/calibre/utils/https.py +++ b/src/calibre/utils/https.py @@ -6,14 +6,12 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -import ssl, socket, re, sys +import ssl, socket, re from contextlib import closing from calibre import get_proxies from calibre.constants import ispy3 -# On OS X PROTOCOL_TLSv1_2 is not available because the SSL library shipped -# with OS X is too old -has_ssl_verify = sys.version_info[:3] > (2, 7, 8) +has_ssl_verify = hasattr(ssl, 'create_default_context') and hasattr(ssl, '_create_unverified_context') class HTTPError(ValueError):