Browse code

Replace pip-installed requests CA bundle with link

If the version of python-requests required is higher than
that provided by the operating system, pip will install
it from upstream.

The upstream version provides its own CA certificate bundle
based on the Mozilla bundle, and defaults to that in case
a CA certificate file is not specified for a request.

The distribution-specific packages point to the system-wide
CA bundle that can be managed by tools such as
update-ca-trust (Fedora/RHEL) and update-ca-certificates
(Debian/Ubuntu).

When installing in SSL/TLS mode, either with SSL=True or by
adding tls-proxy to ENABLED_SERVICES, if a non-systemwide
CA bundle is used, then the CA generated by devstack will
not be used causing the installation to fail.

Replace the upstream-provided bundle with a link to the
system bundle when possible.

Change-Id: I349662ff8f851b4a7f879f89b8975a068f2d73dc
Closes-Bug: #1459789

Rob Crittenden authored on 2015/05/29 03:59:31
Showing 1 changed files
... ...
@@ -138,3 +138,24 @@ fi
138 138
 # and installing the latest version using pip.
139 139
 uninstall_package python-virtualenv
140 140
 pip_install -U virtualenv
141
+
142
+# If a non-system python-requests is installed then it will use the
143
+# built-in CA certificate store rather than the distro-specific
144
+# CA certificate store. Detect this and symlink to the correct
145
+# one. If the value for the CA is not rooted in /etc then we know
146
+# we need to change it.
147
+capath=$(python -c "from requests import certs; print certs.where()")
148
+
149
+if is_service_enabled tls-proxy || [ "$USE_SSL" == "True" ]; then
150
+    if [[ ! $capath =~ ^/etc/.* && ! -L $capath ]]; then
151
+        if is_fedora; then
152
+            sudo rm -f $capath
153
+            sudo ln -s /etc/pki/tls/certs/ca-bundle.crt $capath
154
+        elif is_ubuntu; then
155
+            sudo rm -f $capath
156
+            sudo ln -s /etc/ssl/certs/ca-certificates.crt $capath
157
+        else
158
+            echo "Don't know how to set the CA bundle, expect the install to fail."
159
+        fi
160
+    fi
161
+fi