mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cobbler_sync cobbler_system fix TLS check when validate_certs (#1880)
Ref: https://www.python.org/dev/peps/pep-0476/ Issue #1878 add changelog fragment Co-authored-by: Nicolas Marcq <nicolas.marcq@hpe.com>
This commit is contained in:
parent
bb7ce740fe
commit
36dea9ab97
3 changed files with 18 additions and 12 deletions
2
changelogs/fragments/1880-fix_cobbler_system_ssl.yml
Normal file
2
changelogs/fragments/1880-fix_cobbler_system_ssl.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- cobbler_sync, cobbler_system - fix SSL/TLS certificate check when ``validate_certs`` set to ``false`` (https://github.com/ansible-collections/community.general/pull/1880).
|
|
@ -106,12 +106,14 @@ def main():
|
|||
|
||||
ssl_context = None
|
||||
if not validate_certs:
|
||||
try: # Python 2.7.9 and newer
|
||||
ssl_context = ssl.create_unverified_context()
|
||||
except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default
|
||||
ssl._create_default_context = ssl._create_unverified_context
|
||||
else: # Python 2.7.8 and older
|
||||
ssl._create_default_https_context = ssl._create_unverified_https_context
|
||||
try:
|
||||
ssl_context = ssl._create_unverified_context()
|
||||
except AttributeError:
|
||||
# Legacy Python that doesn't verify HTTPS certificates by default
|
||||
pass
|
||||
else:
|
||||
# Handle target environment that doesn't support HTTPS verification
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
url = '{proto}://{host}:{port}/cobbler_api'.format(**module.params)
|
||||
if ssl_context:
|
||||
|
|
|
@ -229,12 +229,14 @@ def main():
|
|||
|
||||
ssl_context = None
|
||||
if not validate_certs:
|
||||
try: # Python 2.7.9 and newer
|
||||
ssl_context = ssl.create_unverified_context()
|
||||
except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default
|
||||
ssl._create_default_context = ssl._create_unverified_context
|
||||
else: # Python 2.7.8 and older
|
||||
ssl._create_default_https_context = ssl._create_unverified_https_context
|
||||
try:
|
||||
ssl_context = ssl._create_unverified_context()
|
||||
except AttributeError:
|
||||
# Legacy Python that doesn't verify HTTPS certificates by default
|
||||
pass
|
||||
else:
|
||||
# Handle target environment that doesn't support HTTPS verification
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
url = '{proto}://{host}:{port}/cobbler_api'.format(**module.params)
|
||||
if ssl_context:
|
||||
|
|
Loading…
Reference in a new issue