From dcdc79217822adc4311b787aed1c7adabebf3325 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 23 Jan 2016 08:22:23 +0100 Subject: calcurse-caldav: Add a workaround for Python <3.4 Python versions prior to 3.4 do not check certificates by default and thus do not support ssl._create_unverified_context(). Add a workaround. Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 94d1775..edd50d8 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -385,12 +385,19 @@ open(lockfn, 'w') try: # Connect to the server via HTTPs. if insecure_ssl: - context = ssl._create_unverified_context() + try: + context = ssl._create_unverified_context() + conn = http.client.HTTPSConnection(hostname, context=context) + except AttributeError: + # Python versions prior to 3.4 do not support + # ssl._create_unverified_context(). However, these versions do not + # seem to verify certificates by default so we can simply fall back + # to http.client.HTTPSConnection(). + conn = http.client.HTTPSConnection(hostname) else: - context = ssl._create_default_https_context() + conn = http.client.HTTPSConnection(hostname) if verbose: print('Connecting to ' + hostname + '...') - conn = http.client.HTTPSConnection(hostname, context=context) if init: # In initialization mode, start with an empty synchronization database. -- cgit v1.2.3