[core] improvement: new configuration property to disable SSL checking when downloading files

This commit is contained in:
Vinicius Moreira
2022-05-19 17:23:31 -03:00
parent a191748124
commit cefab90052
16 changed files with 60 additions and 7 deletions

View File

@@ -51,7 +51,8 @@ class CoreConfigManager(YAMLConfigManager):
'download': {
'multithreaded': False,
'multithreaded_client': None,
'icons': True
'icons': True,
'check_ssl': True
},
'store_root_password': True,
'disk': {

View File

@@ -23,13 +23,15 @@ RE_HAS_EXTENSION = re.compile(r'.+\.\w+$')
class AdaptableFileDownloader(FileDownloader):
def __init__(self, logger: logging.Logger, multithread_enabled: bool, i18n: I18n, http_client: HttpClient, multithread_client: str):
def __init__(self, logger: logging.Logger, multithread_enabled: bool, i18n: I18n, http_client: HttpClient,
multithread_client: str, check_ssl: bool):
self.logger = logger
self.multithread_enabled = multithread_enabled
self.i18n = i18n
self.http_client = http_client
self.supported_multithread_clients = ['aria2', 'axel']
self.multithread_client = multithread_client
self.check_ssl = check_ssl
@staticmethod
def is_aria2c_available() -> bool:
@@ -75,6 +77,9 @@ class AdaptableFileDownloader(FileDownloader):
def _get_axel_process(self, url: str, output_path: str, cwd: str, root_password: Optional[str], threads: int) -> SimpleProcess:
cmd = ['axel', url, '-n', str(threads), '-4', '-c', '-T', '5']
if not self.check_ssl:
cmd.append('-k')
if output_path:
cmd.append(f'--output={output_path}')
@@ -83,6 +88,9 @@ class AdaptableFileDownloader(FileDownloader):
def _get_wget_process(self, url: str, output_path: str, cwd: str, root_password: Optional[str]) -> SimpleProcess:
cmd = ['wget', url, '-c', '--retry-connrefused', '-t', '10', '--no-config', '-nc']
if not self.check_ssl:
cmd.append('--no-check-certificate')
if output_path:
cmd.append('-O')
cmd.append(output_path)

View File

@@ -128,6 +128,11 @@ class GenericSettingsManager(SettingsController):
value=core_config['system']['single_dependency_checking'],
id_='dep_check')
select_check_ssl = self._gen_bool_component(label=self.i18n['core.config.download.check_ssl'],
tooltip=self.i18n['core.config.download.check_ssl.tip'],
value=core_config['download']['check_ssl'],
id_='download.check_ssl')
select_dmthread = self._gen_bool_component(label=self.i18n['core.config.download.multithreaded'],
tooltip=self.i18n['core.config.download.multithreaded.tip'],
id_="down_mthread",
@@ -135,7 +140,8 @@ class GenericSettingsManager(SettingsController):
select_mthread_client = self._gen_multithread_client_select(core_config)
inputs = [select_dmthread, select_mthread_client, select_trim, select_dep_check, input_data_exp, input_icon_exp]
inputs = [select_dmthread, select_mthread_client, select_check_ssl, select_trim, select_dep_check,
input_data_exp, input_icon_exp]
panel = PanelComponent([FormComponent(inputs, spaces=False)], id_='advanced')
return TabComponent(self.i18n['core.config.tab.advanced'].capitalize(), panel, None, 'core.adv')
@@ -380,9 +386,13 @@ class GenericSettingsManager(SettingsController):
mthread_client = adv_form.get_component('mthread_client', SingleSelectComponent).get_selected()
core_config['download']['multithreaded_client'] = mthread_client
check_ssl = adv_form.get_component('download.check_ssl', SingleSelectComponent).get_selected()
core_config['download']['check_ssl'] = check_ssl
if isinstance(self.file_downloader, AdaptableFileDownloader):
self.file_downloader.multithread_client = mthread_client
self.file_downloader.multithread_enabled = download_mthreaded
self.file_downloader.check_ssl = check_ssl
single_dep_check = adv_form.get_component('dep_check', SingleSelectComponent).get_selected()
core_config['system']['single_dependency_checking'] = single_dep_check