Skip to content
neil edited this page Apr 1, 2022 · 12 revisions

The ACME protocol supported the NotBefore and NotAfter fields of the cert. And some of the CAs supported this feature. (The Letsencrypt CA doesn't support it for now)

There are 2 command options to use:

  1. The --valid-to <date time> option, which is for NotAfter field.
  2. The --valid-from <date time> option, which is for NotBeofre field.

Usage:

1. Set the lifetime of the cert:

acme.sh --issue  -d  example.com  -dns dns_cf    --valid-to  "2022-04-01T08:10:33Z"

The value of --valid-to is an absolute date time in the future. The issued cert will expire on that time(NotAfter).

Please be careful about the date time format, it Must be exact format used above.

You can also use a relative date time format:

# This cert will only be valid for `10` days.

acme.sh  --issue  -d example.com --dns dns_cf   --valid-to  "+10d"


# This cert will be valid for `30` hours.

acme.sh  --issue  -d example.com --dns dns_cf   --valid-to  "+30h"

Please be careful about the format, there are only +*d (for days) and +*h (for hours) supported for now. Any other format will not be accepted.

2. Set the beginning time of the cert:

acme.sh  --issue  -d example.com --dns dns_cf   --valid-from  "2022-04-01T08:10:33Z"

The cert time will be valid starting from "2022-04-01T08:10:33Z".

You can also use the relative time format:


#The cert will be valid in 2 hours:

acme.sh  --issue  -d example.com --dns dns_cf   --valid-from  "+2h"


#The cert will be valid in 1 day:

acme.sh  --issue  -d example.com --dns dns_cf   --valid-from  "+1d"


3. You can use them both at the same time:

# The cert will be valid from `"2022-04-01T08:10:33Z"`, and then live for 40 days to expire:

acme.sh  --issue  -d example.com --dns dns_cf   --valid-from  "2022-04-01T08:10:33Z"   --valid-to "+40d"


# The cert will be valid in 2 hours, and then live for 50 days to expire:

acme.sh  --issue  -d example.com --dns dns_cf   --valid-from  "+2h"  --valid-to "+50d"

4. If the lifetime is measured in hours, you need to change the default crontab to run acme.sh every an hour:

0 * * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
Clone this wiki locally