From 2529f69fbaae7115b7659b4b5790432e70c4d00e Mon Sep 17 00:00:00 2001 From: DQ Date: Thu, 17 Oct 2019 07:28:53 +0000 Subject: [PATCH] All certs in /harbor_cust_certs will appended to ca_bundle Signed-off-by: DQ --- make/photon/common/install_cert.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/make/photon/common/install_cert.sh b/make/photon/common/install_cert.sh index 6b7775b77..c11f2abf9 100755 --- a/make/photon/common/install_cert.sh +++ b/make/photon/common/install_cert.sh @@ -2,17 +2,30 @@ set -e -if [ ! -f /etc/pki/tls/certs/ca-bundle.crt.original ]; then - cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.original +if [ ! -f ~/ca-bundle.crt.original ]; then + cp /etc/pki/tls/certs/ca-bundle.crt ~/ca-bundle.crt.original fi -if [ -f /harbor_cust_cert/custom-ca-bundle.crt ]; then +cp ~/ca-bundle.crt.original /etc/pki/tls/certs/ca-bundle.crt + +if [ "$(ls -A /harbor_cust_cert)" ]; then if grep -q "Photon" /etc/lsb-release; then - echo "Appending custom ca bundle ..." - cp /etc/pki/tls/certs/ca-bundle.crt.original /etc/pki/tls/certs/ca-bundle.crt - cat /harbor_cust_cert/custom-ca-bundle.crt >> /etc/pki/tls/certs/ca-bundle.crt - echo "Done." + echo "Appending trust CA to ca-bundle ..." + for z in /harbor_cust_cert/*; do + case ${z} in + *.crt | *.ca | *.ca-bundle | *.pem) + if [ -d "$z" ]; then + echo "$z is dirictory, skip it ..." + else + cat $z >> /etc/pki/tls/certs/ca-bundle.crt + echo " $z Appended ..." + fi + ;; + *) echo "$z is Not ca file ..." ;; + esac + done + echo "CA appending is Done." else echo "Current OS is not Photon, skip appending ca bundle" fi -fi \ No newline at end of file +fi