diff --git a/changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml b/changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml new file mode 100644 index 0000000000..35bfa33fe6 --- /dev/null +++ b/changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml @@ -0,0 +1,2 @@ +bugfixes: + - rhn_channel - Python 2.7.5 fails if the certificate should not be validated. Fixed this by creating the correct ``ssl_context`` (https://github.com/ansible-collections/community.general/pull/470). diff --git a/plugins/modules/packaging/os/rhn_channel.py b/plugins/modules/packaging/os/rhn_channel.py index 69caacf377..63be03230c 100644 --- a/plugins/modules/packaging/os/rhn_channel.py +++ b/plugins/modules/packaging/os/rhn_channel.py @@ -135,7 +135,7 @@ def main(): 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 + ssl_context = ssl._create_unverified_context() else: # Python 2.7.8 and older ssl._create_default_https_context = ssl._create_unverified_https_context