diff --git a/headphones/__init__.py b/headphones/__init__.py index 380a31bf..821fb202 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -292,6 +292,8 @@ JOURNAL_MODE = None UMASK = None +VERIFY_SSL_CERT = True + def CheckSection(sec): """ Check if INI section exists, if not create it """ try: @@ -360,7 +362,7 @@ def initialize(): XBMC_NOTIFY, LMS_ENABLED, LMS_HOST, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \ PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \ PLEX_ENABLED, PLEX_SERVER_HOST, PLEX_CLIENT_HOST, PLEX_USERNAME, PLEX_PASSWORD, PLEX_UPDATE, PLEX_NOTIFY, PUSHALOT_ENABLED, PUSHALOT_APIKEY, \ - PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED + PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED, VERIFY_SSL_CERT if __INITIALIZED__: @@ -643,6 +645,8 @@ def initialize(): ALBUM_COMPLETION_PCT = check_setting_int(CFG, 'Advanced', 'album_completion_pct', 80) + VERIFY_SSL_CERT = bool(check_setting_int(CFG, 'Advanced', 'verify_ssl_cert', True)) + # update folder formats in the config & bump up config version if CONFIG_VERSION == '0': from headphones.helpers import replace_all @@ -1092,6 +1096,7 @@ def config_write(): new_config['Advanced']['album_completion_pct'] = ALBUM_COMPLETION_PCT new_config['Advanced']['cache_sizemb'] = CACHE_SIZEMB new_config['Advanced']['journal_mode'] = JOURNAL_MODE + new_config['Advanced']['verify_ssl_cert'] = VERIFY_SSL_CERT new_config.write() diff --git a/headphones/request.py b/headphones/request.py index bbb517a9..612d8679 100644 --- a/headphones/request.py +++ b/headphones/request.py @@ -5,6 +5,7 @@ from bs4 import BeautifulSoup import requests import feedparser +import headphones def request_response(url, method="get", auto_raise=True, whitelist_status_code=None, **kwargs): """ @@ -17,6 +18,10 @@ def request_response(url, method="get", auto_raise=True, whitelist_status_code=N if whitelist_status_code and type(whitelist_status_code) != list: whitelist_status_code = [whitelist_status_code] + # Disable verification of SSL certificates if requested. Note: this could + # pose a security issue! + kwargs["verify"] = headphones.VERIFY_SSL_CERT + # Map method to the request.XXX method. This is a simple hack, but it allows # requests to apply more magic per method. See lib/requests/api.py. request_method = getattr(requests, method.lower())