Skip to content

Commit

Permalink
Check if OpenSSL is availabile
Browse files Browse the repository at this point in the history
Ensures the script fails fast if the `openssl` command is not installed or available in the user's PATH.
Print an error message and exits with a non-zero status if `openssl` is unavailable.

This change improves robustness by preventing the script from proceeding when a critical dependency is missing.

Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
  • Loading branch information
gciavarrini committed Dec 12, 2024
1 parent 400b3f0 commit a496003
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/create-new-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ createCert() {
trap "rm -f $csr_file" EXIT
csr_name="$(echo ${RANDOM} | shasum | head -c 40)"

# Check if openssl is available
if ! command -v openssl &>/dev/null; then
echo "Error: 'openssl' is not installed or not available in PATH." >&2
exit 1
fi

openssl req -new -newkey rsa:4096 \
-keyout "${priv_key_file}" \
-out "${csr_file}" \
Expand Down

0 comments on commit a496003

Please sign in to comment.