summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2017-02-03 20:39:12 -0800
committerToshio Kuratomi <a.badger@gmail.com>2017-02-06 13:10:25 -0800
commit7b2fcb2d4ed283290197fde8eb20166f26de8582 (patch)
tree46827b1c84dfed09c08be02871b7014c72d6be59
parent4e257fad842ec8556ce53268e644fec4607e194c (diff)
downloadansible-7b2fcb2d4ed283290197fde8eb20166f26de8582.tar.gz
Make sure that we're comparing text all the way through.
On Darwin, sys.platform returns byte strings on both python2 and python3. Turn it into a text string everywhere in order to remedy that. Fixes #19845 (cherry picked from commit bfffd1952fe140482cae2a2fec52e704cfad04e7)
-rw-r--r--lib/ansible/module_utils/urls.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py
index 4320ba7b8b..834ee9d705 100644
--- a/lib/ansible/module_utils/urls.py
+++ b/lib/ansible/module_utils/urls.py
@@ -115,7 +115,7 @@ import ansible.module_utils.six.moves.urllib.request as urllib_request
import ansible.module_utils.six.moves.urllib.error as urllib_error
from ansible.module_utils.basic import get_distribution, get_exception
from ansible.module_utils.six import b
-from ansible.module_utils._text import to_bytes
+from ansible.module_utils._text import to_bytes, to_text
try:
# python3
@@ -576,21 +576,21 @@ class SSLValidationHandler(urllib_request.BaseHandler):
ca_certs = []
paths_checked = []
- system = platform.system()
+ system = to_text(platform.system(), errors='surrogate_or_strict')
# build a list of paths to check for .crt/.pem files
# based on the platform type
paths_checked.append('/etc/ssl/certs')
- if system == 'Linux':
+ if system == u'Linux':
paths_checked.append('/etc/pki/ca-trust/extracted/pem')
paths_checked.append('/etc/pki/tls/certs')
paths_checked.append('/usr/share/ca-certificates/cacert.org')
- elif system == 'FreeBSD':
+ elif system == u'FreeBSD':
paths_checked.append('/usr/local/share/certs')
- elif system == 'OpenBSD':
+ elif system == u'OpenBSD':
paths_checked.append('/etc/ssl')
- elif system == 'NetBSD':
+ elif system == u'NetBSD':
ca_certs.append('/etc/openssl/certs')
- elif system == 'SunOS':
+ elif system == u'SunOS':
paths_checked.append('/opt/local/etc/openssl/certs')
# fall back to a user-deployed cert in a standard
@@ -602,7 +602,7 @@ class SSLValidationHandler(urllib_request.BaseHandler):
to_add = False
# Write the dummy ca cert if we are running on Mac OS X
- if system == 'Darwin':
+ if system == u'Darwin':
os.write(tmp_fd, b_DUMMY_CA_CERT)
# Default Homebrew path for OpenSSL certs
paths_checked.append('/usr/local/etc/openssl')