mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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:
parent
ac0770ff55
commit
fad7935abc
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
|
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:
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue