From 9f13a4235595886c4059b63e806a783a6b093057 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Tue, 29 Mar 2022 18:42:28 +0200 Subject: [PATCH] Handle the case where --days argument is not a number or a negative one Before this test, the error was displayed but ignored and the certificate was still created depending on the default_days value in openssl.cnf --- shellpki | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shellpki b/shellpki index 69507af..4b97396 100755 --- a/shellpki +++ b/shellpki @@ -502,8 +502,13 @@ create() { # Set expiration argument crt_expiration_arg="" - if [ -n "${days}" ] && [ "${days}" -gt 0 ]; then - crt_expiration_arg="-days ${days}" + if [ -n "${days}" ]; then + if [ "${days}" -gt 0 ]; then + crt_expiration_arg="-days ${days}" + else + error "Argument error: \"${days}\" is not a valid value for \`--days'." + echo $days + fi fi if [ -n "${end_date}" ]; then if [ "${SYSTEM}" = "linux" ]; then