Richard T Bonhomme 9fda11d04f
Replace the original cert_dates() function with extensible wrappers.
The original cert_dates(); was intended to restrict certificate renewal
to a fixed 30-day-window of the certificate expiry date.  This was an
unnecessary restriction. Removed-by: #594

The original cert_dates(); "gave rise to" the Easy-RSA "ambition" to
support multiple versions of 'date' (*nix), which proved to be more
demanding than initially expected. The "new" code speaks for itself.

Currently supported versions of 'date', as of this pull request:
* Linux (Standard Ubuntu)
* FreeBSD
* MacOS and MacOS Ports
* busybox

New functions:

* cert_date_to_timestamp_s()
  Takes* an X509 certificate date, as output by SSL option '-startdate'
  or '-enddate' and creates a 'timestamp' in seconds since epoch.

* offset_days_to_cert_date() [Note: 'days' not 'date']
  Adds* the $offset number of days to the current date and creates an
  X509 "style" certificate date string.

* ff_date_to_cert_date()
  Takes* a fixed-format date and converts it into an X509 certificate
  "style" date string.

* ssl_cert_not_before_date()
  Dedicated function to return an X509 certificate '-startdate' by SSL.

* ssl_cert_not_after_date()
  Dedicated function to return an X509 certificate '-enddate' by SSL.

These functions serve to provide an extensible frame-work for Easy-RSA
to manage all 'date' requirements.

Extras:

Built in reports 'show-expire','show-revoke' and 'show-renew' all use
these functions to interrogate index.txt and the PKI, extensively.

Add error detection to Easy-RSA options which involve "number of days"
and fail for any input which is not a base-10 number. eg. --days=nn

Closes: #593

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 00:59:54 +01:00
..