Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easyrsa-tools.lib: Rename will_cert_expire() -> is_cert_valid() #1216

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions dev/easyrsa-tools.lib
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,15 @@ cert_date_to_iso_8601: force_set_var - $2 - $out_date"
} # => cert_date_to_iso_8601()

# Certificate expiry
will_cert_expire() {
[ -f "$1" ] || die "will_cert_expire - Missing file"
will_cert_be_valid() {
[ -f "$1" ] || die "will_cert_be_valid - Missing file"
case "$2" in (*[!1234567890]*|0*)
die "will_cert_expire - Non-decimal" ;;
die "will_cert_be_valid - Non-decimal" ;;
esac

# is the cert still valid at this future date
"$EASYRSA_OPENSSL" x509 -in "$1" -noout -checkend "$2"
} # => will_cert_expire()

} # => will_cert_be_valid()

# SC2295: Expansion inside ${..} need to be quoted separately,
# otherwise they match as patterns. (what-ever that means ;-)
Expand Down Expand Up @@ -686,9 +686,11 @@ read_db() {
ca_enddate="${ca_enddate#*=}"

# Check CA for expiry
if ! will_cert_expire "$EASYRSA_PKI"/ca.crt \
if will_cert_be_valid "$EASYRSA_PKI"/ca.crt \
"$pre_expire_window_s" 1>/dev/null
then
: # cert will still be valid by expiry window
else
# Print CA expiry date
printf '%s%s\n' \
"CA certificate will expire on $ca_enddate"
Expand All @@ -713,10 +715,10 @@ expire_status_v2() {
if [ -f "$1" ]; then
verbose "expire_status: cert exists"

if will_cert_expire "$1" "$pre_expire_window_s" \
if will_cert_be_valid "$1" "$pre_expire_window_s" \
1>/dev/null
then
: # cert will NOT expire
: # cert will still be valid by expiry window
else
# cert will expire
# ISO8601 date - OpenSSL v3 only
Expand Down