Skip to content

Commit 691c6b2

Browse files
Merge pull request #2914 from craigcomstock/ENT-11875/3.21
Added check for SubjectAltNameWarning exception in distributed_cleanup.py (3.21)
2 parents 2e0d378 + bcc22b8 commit 691c6b2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

templates/federated_reporting/nova_api.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ def __init__(
6969
basic_auth="{}:{}".format(self._api_user, self._api_password)
7070
)
7171
self._headers["Content-Type"] = "application/json"
72-
# In order to avoid SubjectAltNameWarning with our self-signed certs, silence it
73-
if not sys.warnoptions:
74-
import warnings
75-
76-
warnings.simplefilter(
77-
"ignore", category=urllib3.exceptions.SubjectAltNameWarning
78-
)
72+
# urllib3 v2.0 removed SubjectAltNameWarning and instead throws an error if no SubjectAltName is present in a certificate
73+
if hasattr(urllib3.exceptions, "SubjectAltNameWarning"):
74+
# if urllib3 is < v2.0 then SubjectAltNameWarning will exist and should be silenced
75+
if not sys.warnoptions:
76+
import warnings
77+
78+
warnings.simplefilter(
79+
"ignore", category=urllib3.exceptions.SubjectAltNameWarning
80+
)
7981

8082
def __str__(self):
8183
return str(self.__class__) + ":" + str(self.__dict__)

0 commit comments

Comments
 (0)