@@ -103,6 +103,7 @@ function comanage_utils::consume_injected_environment() {
103103 COMANAGE_REGISTRY_VIRTUAL_HOST_FQDN
104104 HTTPS_CERT_FILE
105105 HTTPS_PRIVKEY_FILE
106+ HTTPS_CHAIN_FILE
106107 SERVER_NAME
107108 )
108109
333334# Globals:
334335# HTTPS_CERT_FILE
335336# HTTPS_PRIVKEY_FILE
337+ # HTTPS_CHAIN_FILE
336338# Arguments:
337339# None
338340# Returns:
@@ -347,10 +349,14 @@ function comanage_utils::prepare_https_cert_key() {
347349 if [[ -e ' /etc/debian_version' ]]; then
348350 cert_path=' /etc/apache2/cert.pem'
349351 privkey_path=' /etc/apache2/privkey.pem'
352+ chain_path=' /etc/apache2/ca-chain.pem'
353+ ssl_conf_file=' /etc/apache2/sites-available/000-comanage.conf'
350354 web_user=' www-data'
351355 elif [[ -e ' /etc/centos-release' ]]; then
352356 cert_path=' /etc/httpd/cert.pem'
353357 privkey_path=' /etc/httpd/privkey.pem'
358+ chain_path=' /etc/httpd/ca-chain.pem'
359+ ssl_conf_file=' /etc/httpd/conf.d/000-comanage.conf'
354360 web_user=' apache'
355361 fi
356362
@@ -374,6 +380,21 @@ function comanage_utils::prepare_https_cert_key() {
374380 echo " Copied HTTPS private key file ${HTTPS_PRIVKEY_FILE} to ${privkey_path} " > " $OUTPUT "
375381 echo " Set ownership of ${privkey_path} to ${web_user} " > " $OUTPUT "
376382 fi
383+
384+ # If a chain file is defined, use configured location of the Apache HTTP
385+ # Server certificate chain and uncomment the SSLCertificateChainFile
386+ # option from the apache config file
387+ if [[ -n " ${HTTPS_CHAIN_FILE} " ]]; then
388+ rm -f " ${chain_path} "
389+ cp " ${HTTPS_CHAIN_FILE} " " ${chain_path} "
390+ chown " ${web_user} " " ${chain_path} "
391+ chmod 0644 " ${chain_path} "
392+ sed -i -e ' s/^#SSLCertificateChainFile/SSLCertificateChainFile' ${ssl_config_file}
393+ sed -i -e " s/%%CHAIN_PATH%%/${chain_path} " ${ssl_config_file}
394+ echo " Copied HTTPS CA Chain file ${HTTPS_CHAIN_FILE} to ${chain_path} " > " $OUTPUT "
395+ echo " Set ownership of ${chain_path} to ${web_user} " > " $OUTPUT "
396+ echo " Configured apache to use SSLCertificateChainFile=${chain_path} " > " $OUTPUT "
397+ fi
377398}
378399
379400# #########################################
0 commit comments