From 3fa4a9c07310a1223bbc464a6f9c73cf1d18a992 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 3 Jan 2021 11:37:40 +0100 Subject: [PATCH] Legacy Python certificate validation fixed (#470) (#1576) * Legacy Python certificate validation fixed * added changelog fragment * removed blank line for sanity checks * Update changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml Co-authored-by: Andrew Klychkov * Update changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml Co-authored-by: jpe Co-authored-by: Felix Fontein Co-authored-by: Andrew Klychkov (cherry picked from commit df9f0741b521e3638df69783c82b829c1ea1b06a) Co-authored-by: Johannes Petz --- .../470-spacewalk-legacy-python-certificate-validation.yaml | 2 ++ plugins/modules/packaging/os/rhn_channel.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/470-spacewalk-legacy-python-certificate-validation.yaml 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