@@ -1015,6 +1015,24 @@ _checkcert() {
10151015 fi
10161016}
10171017
1018+ # file
1019+ _enddate () {
1020+ _cf=" $1 "
1021+ _res=" $( ${ACME_OPENSSL_BIN:- openssl} x509 -noout -enddate -in " $_cf " ) "
1022+ if [ " $? " != " 0" ] || [ -z " $_res " ]; then
1023+ return 1
1024+ fi
1025+
1026+ case " $_res " in
1027+ notAfter=* )
1028+ echo " ${_res# notAfter=} "
1029+ ;;
1030+ * )
1031+ return 1
1032+ ;;
1033+ esac
1034+ }
1035+
10181036# Usage: hashalg [outputhex]
10191037# Output Base64-encoded digest
10201038_digest () {
@@ -1846,6 +1864,25 @@ _date2time() {
18461864 return 1
18471865}
18481866
1867+ # support the output format of openssl -enddate:
1868+ # Apr 01 08:10:33 2022 GMT to 1641283833
1869+ _ssldate2time () {
1870+ # Linux
1871+ if date -u -d " $1 " +" %s" 2> /dev/null; then
1872+ return
1873+ fi
1874+ # Solaris
1875+ if gdate -u -d " $1 " +" %s" 2> /dev/null; then
1876+ return
1877+ fi
1878+ # Mac/BSD
1879+ if date -j -f " %b %d %T %Y %Z" " $1 " +" %s" 2> /dev/null; then
1880+ return
1881+ fi
1882+ _err " Cannot parse _ssldate2time $1 "
1883+ return 1
1884+ }
1885+
18491886_utc_date () {
18501887 date -u " +%Y-%m-%d %H:%M:%S"
18511888}
@@ -5564,7 +5601,7 @@ $_authorizations_map"
55645601 Le_CertCreateTimeStr=$( _time2str " $Le_CertCreateTime " )
55655602 _savedomainconf " Le_CertCreateTimeStr" " $Le_CertCreateTimeStr "
55665603
5567- if [ -z " $Le_RenewalDays " ] || [ " $Le_RenewalDays " -lt " 0 " ] ; then
5604+ if [ -z " $Le_RenewalDays " ]; then
55685605 Le_RenewalDays=" $DEFAULT_RENEW "
55695606 else
55705607 _savedomainconf " Le_RenewalDays" " $Le_RenewalDays "
@@ -5623,6 +5660,20 @@ $_authorizations_map"
56235660 Le_NextRenewTimeStr=$( _time2str " $Le_NextRenewTime " )
56245661 fi
56255662 fi
5663+ elif [ " $Le_RenewalDays " -lt " 0" ]; then
5664+ _enddate_value=$( _enddate " $CERT_PATH " )
5665+ if [ " $? " != " 0" ] || [ -z " $_enddate_value " ]; then
5666+ _err " Failed to get certificate end date for $CERT_PATH "
5667+ return 1
5668+ fi
5669+
5670+ _endtime=$( _ssldate2time " $_enddate_value " )
5671+ if [ " $? " != " 0" ] || [ -z " $_endtime " ]; then
5672+ _err " Cannot parse _enddate_value: $_enddate_value "
5673+ return 1
5674+ fi
5675+ Le_NextRenewTime=$( _math " $_endtime " + " $Le_RenewalDays " \* 24 \* 60 \* 60)
5676+ Le_NextRenewTimeStr=$( _time2str " $Le_NextRenewTime " )
56265677 else
56275678 Le_NextRenewTime=$( _math " $Le_CertCreateTime " + " $Le_RenewalDays " \* 24 \* 60 \* 60)
56285679 Le_NextRenewTime=$( _math " $Le_NextRenewTime " - 86400)
@@ -7446,6 +7497,7 @@ Parameters:
74467497 -m, --email <email> Specifies the account email, only valid for the '--install' and '--update-account' command.
74477498 --accountkey <file> Specifies the account key path, only valid for the '--install' command.
74487499 --days <ndays> Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days.
7500+ Negative values could be used to specify a number of days relative to the expiration date of the certificate.
74497501 --httpport <port> Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
74507502 --tlsport <port> Specifies the standalone tls listening port. Only valid if the server is behind a reverse proxy or load balancer.
74517503 --local-address <ip> Specifies the standalone/tls server listening address, in case you have multiple ip addresses.
0 commit comments