Create fallback cert if not passed in via user data

This commit is contained in:
Johannes Zellner
2016-10-21 11:57:24 +02:00
committed by Girish Ramakrishnan
parent 09b4325ecc
commit db55a7ad3c

View File

@@ -123,8 +123,13 @@ if [[ -f "${DATA_DIR}/box/certs/host.cert" && -f "${DATA_DIR}/box/certs/host.key
cp "${DATA_DIR}/box/certs/host.cert" "${DATA_DIR}/nginx/cert/host.cert"
cp "${DATA_DIR}/box/certs/host.key" "${DATA_DIR}/nginx/cert/host.key"
else
echo "${arg_tls_cert}" > "${DATA_DIR}/nginx/cert/host.cert"
echo "${arg_tls_key}" > "${DATA_DIR}/nginx/cert/host.key"
if [[ -z "${arg_tls_cert}" || -z "${arg_tls_key}" ]]; then
echo "Creating fallback certs"
openssl req -x509 -newkey rsa:2048 -keyout "${DATA_DIR}/nginx/cert/host.key" -out "${DATA_DIR}/nginx/cert/host.cert" -days 3650 -subj "/CN=${arg_fqdn}" -nodes
else
echo "${arg_tls_cert}" > "${DATA_DIR}/nginx/cert/host.cert"
echo "${arg_tls_key}" > "${DATA_DIR}/nginx/cert/host.key"
fi
fi
set_progress "33" "Changing ownership"