1
0
Fork 0
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) (#1901)

Ref: https://www.python.org/dev/peps/pep-0476/
Issue #1878
add changelog fragment

Co-authored-by: Nicolas Marcq <nicolas.marcq@hpe.com>
(cherry picked from commit 36dea9ab97)

Co-authored-by: Nicolas Marcq <nico.marcq@gmail.com>
This commit is contained in:
patchback[bot] 2021-02-25 15:17:40 +01:00 committed by GitHub
parent ac0770ff55
commit fad7935abc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View 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).

View file

@ -106,12 +106,14 @@ def main():
ssl_context = None ssl_context = None
if not validate_certs: if not validate_certs:
try: # Python 2.7.9 and newer try:
ssl_context = ssl.create_unverified_context() ssl_context = ssl._create_unverified_context()
except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default except AttributeError:
ssl._create_default_context = ssl._create_unverified_context # Legacy Python that doesn't verify HTTPS certificates by default
else: # Python 2.7.8 and older pass
ssl._create_default_https_context = ssl._create_unverified_https_context 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) url = '{proto}://{host}:{port}/cobbler_api'.format(**module.params)
if ssl_context: if ssl_context:

View file

@ -229,12 +229,14 @@ def main():
ssl_context = None ssl_context = None
if not validate_certs: if not validate_certs:
try: # Python 2.7.9 and newer try:
ssl_context = ssl.create_unverified_context() ssl_context = ssl._create_unverified_context()
except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default except AttributeError:
ssl._create_default_context = ssl._create_unverified_context # Legacy Python that doesn't verify HTTPS certificates by default
else: # Python 2.7.8 and older pass
ssl._create_default_https_context = ssl._create_unverified_https_context 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) url = '{proto}://{host}:{port}/cobbler_api'.format(**module.params)
if ssl_context: if ssl_context: