From 1fa4ff205e5ac39ebc49d6a44f313ae4567dd2ec Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Mon, 4 Apr 2022 17:01:19 +0200 Subject: [PATCH] Parse date in ISO format rather than US format --- README.md | 2 +- shellpki | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 29353ec..1c786d7 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Options -p, --password prompt the user for a password to set on the client key --password-file if provided with a path to a readable file, the first line is read and set as password on the client key --days specify how many days the certificate should be valid - --end-date specify until which date the certificate should be valid, in MM/DD/YYYY hh:mm:ss format + --end-date specify until which date the certificate should be valid, in YYYY/MM/DD hh:mm:ss format --non-interactive do not prompt the user, and exit if an error occurs --replace-existing if the certificate already exists, revoke it before creating a new one ~~~ diff --git a/shellpki b/shellpki index 663020b..79bd8b0 100755 --- a/shellpki +++ b/shellpki @@ -50,7 +50,7 @@ Create a client certificate with key and CSR directly generated on server : -p, --password prompt the user for a password to set on the client key --password-file if provided with a path to a readable file, the first line is read and set as password on the client key --days specify how many days the certificate should be valid - --end-date specify until which date the certificate should be valid, in "MM/DD/YYYY hh:mm:ss" format + --end-date specify until which date the certificate should be valid, in "YYYY/MM/DD hh:mm:ss" format --non-interactive do not prompt the user, and exit if an error occurs --replace-existing if the certificate already exists, revoke it before creating a new one @@ -515,15 +515,15 @@ create() { cert_end_date=$(TZ=:Zulu date --date "${end_date}" +"%Y%m%d%H%M%SZ" 2> /dev/null) # shellcheck disable=SC2181 if [ "$?" -ne 0 ]; then - error "Invalid end date format: \`${end_date}' can't be parsed by date(1). Expected format: MM/DD/[YY]YY [hh[:mm[:ss]]]." + error "Invalid end date format: \`${end_date}' can't be parsed by date(1). Expected format: YYYY/MM/DD [hh[:mm[:ss]]]." else crt_expiration_arg="-enddate ${cert_end_date}" fi elif [ "${SYSTEM}" = "openbsd" ]; then - cert_end_date=$(TZ=:Zulu date -f "%m/%d/%C%y %H:%M:%S" -j "${end_date}" +"%Y%m%d%H%M%SZ" 2> /dev/null) + cert_end_date=$(TZ=:Zulu date -f "%C%y/%m/%d %H:%M:%S" -j "${end_date}" +"%Y%m%d%H%M%SZ" 2> /dev/null) # shellcheck disable=SC2181 if [ "$?" -ne 0 ]; then - error "Invalid end date format: \`${end_date}' can't be parsed by date(1). Expected format: MM/DD/YYYY hh:mm:ss." + error "Invalid end date format: \`${end_date}' can't be parsed by date(1). Expected format: YYYY/MM/DD hh:mm:ss." else crt_expiration_arg="-enddate ${cert_end_date}" fi