diff --git a/SABnzbd.py b/SABnzbd.py index 25ee266..68392f7 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -714,7 +714,10 @@ def is_sabnzbd_running(url, timeout=None): """ Return True when there's already a SABnzbd instance running. """ try: url = '%s&mode=version' % (url) + # Do this without certificate verification, few installations will have that + prev = sabnzbd.set_https_verification(False) ver = sabnzbd.newsunpack.get_from_url(url, timeout=timeout) + sabnzbd.set_https_verification(prev) return bool(ver and re.search(r'\d+\.\d+\.', ver)) except: return False diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 5139317..8441382 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -486,18 +486,24 @@ def guard_fsys_type(): """ Callback for change of file system naming type """ sabnzbd.encoding.change_fsys(cfg.fsys_type()) - -def guard_https_ver(): - """ Callback for change of https verification """ +def set_https_verification(value): + prev = False try: import ssl if hasattr(ssl, '_create_default_https_context'): - if cfg.enable_https_verification(): + prev = ssl._create_default_https_context == ssl.create_default_context + if value: ssl._create_default_https_context = ssl.create_default_context else: ssl._create_default_https_context = ssl._create_unverified_context except ImportError: pass + return prev + + +def guard_https_ver(): + """ Callback for change of https verification """ + set_https_verification(cfg.enable_https_verification()) def add_url(url, pp=None, script=None, cat=None, priority=None, nzbname=None):