Skip to content

Commit

Permalink
update gencerts.sh
Browse files Browse the repository at this point in the history
Signed-off-by: ChrisLiu <[email protected]>
  • Loading branch information
chrisliu1995 committed Sep 26, 2022
1 parent f1d2929 commit a18f9be
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions hack/gencerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
# Generates a CA certificate, a server key, and a server certificate signed by the CA.

set -e
SCRIPT=`basename ${BASH_SOURCE[0]}`

SCRIPT=$(basename "${BASH_SOURCE[0]}")
function usage {
cat<< EOF
Usage: $SCRIPT
Expand Down Expand Up @@ -117,10 +116,10 @@ if [[ "$IN_POD" == "true" ]]; then
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)

# Base64 encode secrets and then remove the trailing newline to avoid issues in the curl command
ca_cert=$(cat ${TMP_DIR}/ca-cert.pem | base64 | tr -d '\n')
ca_key=$(cat ${TMP_DIR}/ca-key.pem | base64 | tr -d '\n')
server_cert=$(cat ${TMP_DIR}/server-cert.pem | base64 | tr -d '\n')
server_key=$(cat ${TMP_DIR}/server-key.pem | base64 | tr -d '\n')
ca_cert=$(cmd file | ${TMP_DIR}/ca-cert.pem | base64 | tr -d '\n')
ca_key=$(cmd file | ${TMP_DIR}/ca-key.pem | base64 | tr -d '\n')
server_cert=$(cmd file | ${TMP_DIR}/server-cert.pem | base64 | tr -d '\n')
server_key=$(cmd file | ${TMP_DIR}/server-key.pem | base64 | tr -d '\n')

# Create the secret resource
echo "Creating a secret for the certificate and keys"
Expand Down Expand Up @@ -166,5 +165,5 @@ else
fi

# Clean up after we're done.
printf "\nDeleting ${TMP_DIR}.\n"
printf "\nDeleting %s.\n" "${TMP_DIR}"
rm -rf ${TMP_DIR}

0 comments on commit a18f9be

Please sign in to comment.