Skip to content

Commit

Permalink
Disable insecure request warning
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jesusbv committed May 14, 2024
1 parent 1b973a4 commit 4ff2c57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/cloudregister/registerutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()


Expand Down
7 changes: 7 additions & 0 deletions lib/cloudregister/smt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -148,6 +154,7 @@ def is_responsive(self):
# or if the IP address is built into the cert. Since we only want
# to know if the system is responsive we ignore cert validation
# Using the IP address protects us from hostname spoofing

for health_url in self._check_urls.keys():
try:
response = requests.get(health_url, timeout=2, verify=False)
Expand Down

0 comments on commit 4ff2c57

Please sign in to comment.