From 0ca3800ae106992e6a6c59f249959c47510cb675 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 3 Jan 2017 22:50:58 -0800 Subject: [PATCH] Fix traceback on Darwin with Python3 os.write() needs bytes objects on python3 while python2 can work with either a byte or unicode string. Mark the DUMMY_CA_CERT string as a byte string so it will work. Fixes #19265 Fixes #19266 --- lib/ansible/module_utils/urls.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index 68f78c0b8ed..4320ba7b8bb 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -309,7 +309,7 @@ if not HAS_MATCH_HOSTNAME: # ca cert, regardless of validity, for Python on Mac OS to use the # keychain functionality in OpenSSL for validating SSL certificates. # See: http://mercurial.selenic.com/wiki/CACertificates#Mac_OS_X_10.6_and_higher -DUMMY_CA_CERT = """-----BEGIN CERTIFICATE----- +b_DUMMY_CA_CERT = b("""-----BEGIN CERTIFICATE----- MIICvDCCAiWgAwIBAgIJAO8E12S7/qEpMA0GCSqGSIb3DQEBBQUAMEkxCzAJBgNV BAYTAlVTMRcwFQYDVQQIEw5Ob3J0aCBDYXJvbGluYTEPMA0GA1UEBxMGRHVyaGFt MRAwDgYDVQQKEwdBbnNpYmxlMB4XDTE0MDMxODIyMDAyMloXDTI0MDMxNTIyMDAy @@ -326,7 +326,7 @@ MUB80IR6knq9K/tY+hvPsZer6eFMzO3JGkRFBh2kn6JdMDnhYGX7AXVHGflrwNQH qFy+aenWXsC0ZvrikFxbQnX8GVtDADtVznxOi7XzFw7JOxdsVrpXgSN0eh0aMzvV zKPZsZ2miVGclicJHzm5q080b1p/sZtuKIEZk6vZqEg= -----END CERTIFICATE----- -""" +""") # # Exceptions @@ -603,7 +603,7 @@ class SSLValidationHandler(urllib_request.BaseHandler): # Write the dummy ca cert if we are running on Mac OS X if system == 'Darwin': - os.write(tmp_fd, DUMMY_CA_CERT) + os.write(tmp_fd, b_DUMMY_CA_CERT) # Default Homebrew path for OpenSSL certs paths_checked.append('/usr/local/etc/openssl')