mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Guard creating HTTPSClientAuthHandler behind HTTPS checks (#50523)
* Guard creating HTTPSClientAuthHandler behind HTTPS checks. Fixes #50339 * linting fixup
This commit is contained in:
parent
4790d77a58
commit
8a2d39bcb2
2 changed files with 26 additions and 23 deletions
2
changelogs/fragments/urls-https-guard.yaml
Normal file
2
changelogs/fragments/urls-https-guard.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- Guard ``HTTPSClientAuthHandler`` under HTTPS checks, to avoid tracebacks when python is compiled without SSL support (https://github.com/ansible/ansible/issues/50339)
|
|
@ -298,7 +298,9 @@ class NoSSLError(SSLValidationError):
|
||||||
|
|
||||||
# Some environments (Google Compute Engine's CoreOS deploys) do not compile
|
# Some environments (Google Compute Engine's CoreOS deploys) do not compile
|
||||||
# against openssl and thus do not have any HTTPS support.
|
# against openssl and thus do not have any HTTPS support.
|
||||||
CustomHTTPSConnection = CustomHTTPSHandler = None
|
CustomHTTPSConnection = None
|
||||||
|
CustomHTTPSHandler = None
|
||||||
|
HTTPSClientAuthHandler = None
|
||||||
if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler'):
|
if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler'):
|
||||||
class CustomHTTPSConnection(httplib.HTTPSConnection):
|
class CustomHTTPSConnection(httplib.HTTPSConnection):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -342,8 +344,7 @@ if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler
|
||||||
|
|
||||||
https_request = AbstractHTTPHandler.do_request_
|
https_request = AbstractHTTPHandler.do_request_
|
||||||
|
|
||||||
|
class HTTPSClientAuthHandler(urllib_request.HTTPSHandler):
|
||||||
class HTTPSClientAuthHandler(urllib_request.HTTPSHandler):
|
|
||||||
'''Handles client authentication via cert/key
|
'''Handles client authentication via cert/key
|
||||||
|
|
||||||
This is a fairly lightweight extension on HTTPSHandler, and can be used
|
This is a fairly lightweight extension on HTTPSHandler, and can be used
|
||||||
|
|
Loading…
Reference in a new issue