File tree 2 files changed +32
-6
lines changed
2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -369,13 +369,31 @@ db_date_to_iso_8601_date: force_set_var - $2 - $out_date"
369
369
370
370
# Certificate expiry
371
371
will_cert_be_valid () {
372
- [ -f " $1 " ] || die " will_cert_be_valid - Missing file"
373
- case " $2 " in (* [!1234567890]* |0* )
374
- die " will_cert_be_valid - Non-decimal" ;;
372
+ # Verify file exists and is a valid cert
373
+ [ -f " $1 " ] || \
374
+ die " will_cert_be_valid - Missing file: $1 "
375
+ verify_file x509 " $1 " || \
376
+ die " will_cert_be_valid - Invalid file: $1 "
377
+
378
+ # Verify --days
379
+ case " $2 " in
380
+ 0) : ;; # ok
381
+ ' ' |* [!1234567890]* |0* )
382
+ die " will_cert_be_valid - Non-decimal value: $2 "
375
383
esac
376
384
377
385
# is the cert still valid at this future date
378
- " $EASYRSA_OPENSSL " x509 -in " $1 " -noout -checkend " $2 "
386
+ ssl_out=" $(
387
+ " $EASYRSA_OPENSSL " x509 -in " $1 " -noout \
388
+ -checkend " $2 "
389
+ ) "
390
+
391
+ # analyse SSL output
392
+ case " $ssl_out " in
393
+ ' Certificate will not expire' ) return 0 ;;
394
+ ' Certificate will expire' ) return 1 ;;
395
+ * ) die " will_cert_be_valid - Failure"
396
+ esac
379
397
} # => will_cert_be_valid()
380
398
381
399
# SC2295: Expansion inside ${..} need to be quoted separately,
@@ -535,8 +553,7 @@ expire_status_v2() {
535
553
if [ -f " $1 " ]; then
536
554
verbose " expire_status: cert exists"
537
555
538
- if will_cert_be_valid " $1 " " $pre_expire_window_s " \
539
- 1> /dev/null
556
+ if will_cert_be_valid " $1 " " $pre_expire_window_s "
540
557
then
541
558
: # cert will still be valid by expiry window
542
559
else
Original file line number Diff line number Diff line change @@ -4338,6 +4338,14 @@ Option --passout cannot be used with --nopass|nopass."
4338
4338
prohibit_no_pass=1
4339
4339
fi
4340
4340
4341
+ # Restrict --days=0 to 'show-expire'
4342
+ if [ "$alias_days" = 0 ]; then
4343
+ case "$cmd" in
4344
+ show-expire) : ;; # ok
4345
+ *) user_error "Cannot use --days=0 for command $cmd"
4346
+ esac
4347
+ fi
4348
+
4341
4349
# --silent-ssl requires --batch
4342
4350
if [ "$EASYRSA_SILENT_SSL" ]; then
4343
4351
[ "$EASYRSA_BATCH" ] || warn "\
@@ -5582,6 +5590,7 @@ while :; do
5582
5590
case "$opt" in
5583
5591
--days)
5584
5592
number_only=1
5593
+ zero_allowed=1
5585
5594
# Set the appropriate date variable
5586
5595
# when called by command later
5587
5596
alias_days="$val"
You can’t perform that action at this time.
0 commit comments