From 022976d2f669e23760242cfe3c0c12cf0b2fb831 Mon Sep 17 00:00:00 2001 From: theguardian Date: Tue, 20 Oct 2015 21:52:55 -0700 Subject: [PATCH] added verify_ssl_cert option to fix broken ssl installs --- Headphones.py | 10 ++++++++++ data/interfaces/default/config.html | 6 ++++++ headphones/config.py | 2 +- headphones/webserve.py | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Headphones.py b/Headphones.py index 0d31534e..713a628b 100755 --- a/Headphones.py +++ b/Headphones.py @@ -177,6 +177,16 @@ def main(): "module to enable HTTPS. HTTPS will be disabled.") headphones.CONFIG.ENABLE_HTTPS = False + #This fix is put in place for systems with broken SSL (like QNAP) + certificate_verification = headphones.CONFIG.VERIFY_SSL_CERT + if not certificate_verification: + try: + import ssl + ssl._create_default_https_context = ssl._create_unverified_context + except: + pass + #==== end block (should be configurable at settings level) + # Try to start the server. Will exit here is address is already in use. web_config = { 'http_port': http_port, diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 5688ce6d..a6f3f6f6 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -80,6 +80,12 @@ +
+ + +
diff --git a/headphones/config.py b/headphones/config.py index 97cc5e6c..9d48f471 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -253,7 +253,7 @@ _CONFIG_DEFINITIONS = { 'UTORRENT_LABEL': (str, 'uTorrent', ''), 'UTORRENT_PASSWORD': (str, 'uTorrent', ''), 'UTORRENT_USERNAME': (str, 'uTorrent', ''), - 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), + 'VERIFY_SSL_CERT': (int, 'Advanced', 1), 'WAIT_UNTIL_RELEASE_DATE' : (int, 'General', 0), 'WAFFLES': (int, 'Waffles', 0), 'WAFFLES_PASSKEY': (str, 'Waffles', ''), diff --git a/headphones/webserve.py b/headphones/webserve.py index 815c5e9f..b7f2874a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1025,6 +1025,7 @@ class WebInterface(object): "enable_https": checked(headphones.CONFIG.ENABLE_HTTPS), "https_cert": headphones.CONFIG.HTTPS_CERT, "https_key": headphones.CONFIG.HTTPS_KEY, + "verify_ssl_cert": checked(headphones.CONFIG.VERIFY_SSL_CERT), "api_enabled": checked(headphones.CONFIG.API_ENABLED), "api_key": headphones.CONFIG.API_KEY, "download_scan_interval": headphones.CONFIG.DOWNLOAD_SCAN_INTERVAL, @@ -1286,7 +1287,7 @@ class WebInterface(object): # Handle the variable config options. Note - keys with False values aren't getting passed checked_configs = [ - "launch_browser", "enable_https", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled", + "launch_browser", "enable_https", "verify_ssl_cert", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled", "use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay", "use_mininova", "use_waffles", "use_rutracker", "use_whatcd", "use_strike", "preferred_bitrate_allow_lossless", "detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files", "rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics",