Browse Source

When trying to connect to another SABnzbd instance over HTTPS, don't verify certificates.

Very few SABnzbd installations will have valid certificates.
pull/441/head
shypike 9 years ago
parent
commit
c5767b061d
  1. 3
      SABnzbd.py
  2. 14
      sabnzbd/__init__.py

3
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

14
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):

Loading…
Cancel
Save