default values for variables in tests

This commit is contained in:
Jérémy Lecour 2020-10-12 23:27:24 +02:00 committed by Jérémy Lecour
parent 75e36189c5
commit c83f210387
1 changed files with 8 additions and 8 deletions

View File

@ -458,7 +458,7 @@ create() {
if [ "${ask_pass}" -eq 1 ]; then
warning "Warning: -p|--password is ignored with -f|--file|--crt-file"
fi
if [ -n "${password_file}" ]; then
if [ -n "${password_file:-}" ]; then
warning "Warning: --password-file is ignored with -f|--file|--crt-file"
fi
@ -539,9 +539,9 @@ create() {
# generate private key
pass_args=""
if [ -n "${password_file}" ]; then
if [ -n "${password_file:-}" ]; then
pass_args="-aes256 -passout file:${password_file}"
elif [ -n "${PASSWORD}" ]; then
elif [ -n "${PASSWORD:-}" ]; then
pass_args="-aes256 -passout pass:${PASSWORD}"
fi
"${OPENSSL_BIN}" genrsa \
@ -557,9 +557,9 @@ create() {
# generate csr req
pass_args=""
if [ -n "${password_file}" ]; then
if [ -n "${password_file:-}" ]; then
pass_args="-passin file:${password_file}"
elif [ -n "${PASSWORD}" ]; then
elif [ -n "${PASSWORD:-}" ]; then
pass_args="-passin pass:${PASSWORD}"
fi
"${OPENSSL_BIN}" req \
@ -607,14 +607,14 @@ EOF
# generate pkcs12 format
pass_args=""
if [ -n "${password_file}" ]; then
if [ -n "${password_file:-}" ]; then
# Hack for pkcs12 :
# If passin and passout files are the same path, it expects 2 lines
# so we make a temporary copy of the password file
password_file_out=$(mktemp)
cp "${password_file}" "${password_file_out}"
pass_args="-passin file:${password_file} -passout file:${password_file_out}"
elif [ -n "${PASSWORD}" ]; then
elif [ -n "${PASSWORD:-}" ]; then
pass_args="-passin pass:${PASSWORD} -passout pass:${PASSWORD}"
else
pass_args="-passout pass:"
@ -630,7 +630,7 @@ EOF
error "Error generating the pkcs12 file"
fi
if [ -n "${password_file_out}" ]; then
if [ -n "${password_file_out:-}" ]; then
# Hack for pkcs12 :
# Destroy the temporary file
rm -f "${password_file_out}"