diff --git a/conf/init/certs_install.sh b/conf/init/certs_install.sh index 2ae929ac0..9f440d8a6 100755 --- a/conf/init/certs_install.sh +++ b/conf/init/certs_install.sh @@ -9,7 +9,7 @@ fi # Add extra trusted certificates (as a directory) if [ -d /conf/stack/extra_ca_certs ]; then - if test $(ls -A "/conf/stack/extra_ca_certs"); then + if test "$(ls -A "/conf/stack/extra_ca_certs")"; then echo "Installing extra certificates found in /conf/stack/extra_ca_certs directory" cp /conf/stack/extra_ca_certs/* /usr/local/share/ca-certificates/ cat /conf/stack/extra_ca_certs/* >> /venv/lib/python2.7/site-packages/requests/cacert.pem diff --git a/endpoints/api/superuser.py b/endpoints/api/superuser.py index 9a1da3dea..953c30960 100644 --- a/endpoints/api/superuser.py +++ b/endpoints/api/superuser.py @@ -3,6 +3,7 @@ import logging import os import string +import subprocess import pathvalidate @@ -894,9 +895,27 @@ class SuperUserCustomCertificate(ApiResource): if not uploaded_file: abort(400) + # Save the certificate. certpath = pathvalidate.sanitize_filename(certpath) + if not certpath.endswith('.crt'): + abort(400) + cert_full_path = os.path.join(EXTRA_CA_DIRECTORY, certpath) config_provider.save_volume_file(cert_full_path, uploaded_file) + + # Validate the certificate. + try: + with config_provider.get_volume_file(cert_full_path) as f: + load_certificate(f.read()) + + # Call the update script to install the certificate immediately. + if not app.config['TESTING']: + subprocess.check_call(['/conf/init/certs_install.sh']) + except CertInvalidException: + pass + except IOError: + pass + return '', 204 abort(403) diff --git a/static/directives/config/config-certificates-field.html b/static/directives/config/config-certificates-field.html index 502475672..f20e4c459 100644 --- a/static/directives/config/config-certificates-field.html +++ b/static/directives/config/config-certificates-field.html @@ -12,6 +12,7 @@
Custom certificates are typically used in place of publicly signed certificates for corporate-internal services.
+Please make sure that all custom names used for downstream services (such as Clair) are listed in the certificates below.
Upload certificates: | + reset="resetUpload" + extensions="['.crt']"> |
Authentication Key: | +
+
+
+ The security scanning service requires an authorized service key to speak to Quay. Once setup, the key
+ can be managed in the Service Keys panel under the Super User Admin Panel.
+
+ |
+
Security Scanner Endpoint: |
@@ -351,15 +361,8 @@
The HTTP URL at which the security scanner is running.
- |
-
Authentication Key: | -
-
-
- The security scanning service requires an authorized service key to speak to Quay. Once setup, the key
- can be managed in the Service Keys panel under the Super User Admin Panel.
+
+ Is the security scanner behind a domain signed with a self-signed TLS certificate? If so, please make sure to register your SSL CA in the custom certificates panel above.
|