forked from TrueCloudLab/lego
Add a way for cronjobs to automatically renew certificates.
This commit is contained in:
parent
a528107826
commit
2a9875b220
2 changed files with 19 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/xenolf/lego/acme"
|
||||
|
@ -181,6 +182,17 @@ func renew(c *cli.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if c.IsSet("days") {
|
||||
expTime, err := acme.GetPEMCertExpiration(certBytes)
|
||||
if err != nil {
|
||||
logger().Printf("Could not get Certification expiration for domain %s", domain)
|
||||
}
|
||||
|
||||
if int(expTime.Sub(time.Now()).Hours() / 24.0) <= c.Int("days") {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
keyBytes, err := ioutil.ReadFile(privPath)
|
||||
if err != nil {
|
||||
logger().Printf("Error while loading the private key for domain %s\n\t%v", domain, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue