From 7517d6e47725389c2856361684cb02ed07a8da98 Mon Sep 17 00:00:00 2001 From: Jesus Bermudez Velazquez Date: Wed, 17 Apr 2024 17:46:06 +0100 Subject: [PATCH 1/2] Disable insecure request warning In order to check whether a RMT server is responsive, a https request is triggered with verification disable making the request to show a warning Disable warning for registercloudguest and SMT class This PR silences that warning --- lib/cloudregister/registerutils.py | 7 ++++--- lib/cloudregister/smt.py | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/cloudregister/registerutils.py b/lib/cloudregister/registerutils.py index a41a971b..e2fa356d 100644 --- a/lib/cloudregister/registerutils.py +++ b/lib/cloudregister/registerutils.py @@ -46,6 +46,10 @@ REGISTERED_SMT_SERVER_DATA_FILE_NAME = 'currentSMTInfo.obj' RMT_AS_SCC_PROXY_MARKER = 'rmt_is_scc_proxy' +requests.packages.urllib3.disable_warnings( + requests.packages.urllib3.exceptions.InsecureRequestWarning +) + # ---------------------------------------------------------------------------- def add_hosts_entry(smt_server): @@ -505,9 +509,6 @@ def get_credentials(credentials_file): # ---------------------------------------------------------------------------- def refresh_registry_credentials(): """Refresh registry credentials.""" - # to silence InsecureRequestWarning - # should be fixed on a different PR - requests.packages.urllib3.disable_warnings() return get_activations() diff --git a/lib/cloudregister/smt.py b/lib/cloudregister/smt.py index 5969eecc..7871eee3 100644 --- a/lib/cloudregister/smt.py +++ b/lib/cloudregister/smt.py @@ -47,6 +47,12 @@ def __init__(self, smtXMLNode, https_only=False): if https_only: self._protocol = 'https' self._check_urls = self._form_srv_check_urls() + # disable InsecureRequestWarning + # as verification is disabled for the https request + requests.packages.urllib3.disable_warnings( + requests.packages.urllib3.exceptions.InsecureRequestWarning + ) + # -------------------------------------------------------------------- def __eq__(self, other_smt): From 38544b257132c2bf337d2be6511d87ef531b0cd9 Mon Sep 17 00:00:00 2001 From: Jesus Bermudez Velazquez Date: Tue, 14 May 2024 13:02:22 +0100 Subject: [PATCH 2/2] Fix linter --- lib/cloudregister/smt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cloudregister/smt.py b/lib/cloudregister/smt.py index 7871eee3..b9fee4ed 100644 --- a/lib/cloudregister/smt.py +++ b/lib/cloudregister/smt.py @@ -53,7 +53,6 @@ def __init__(self, smtXMLNode, https_only=False): requests.packages.urllib3.exceptions.InsecureRequestWarning ) - # -------------------------------------------------------------------- def __eq__(self, other_smt): if not isinstance(other_smt, SMT):