aboutsummaryrefslogtreecommitdiff
path: root/cmd/acme/main.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-12 13:32:31 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-12 13:32:31 +0100
commit2ce89488b20aaa6d1464e824b6e2e8ab2f9aceb4 (patch)
tree37c446061f4cc3394d48a60d6252d57d1b29ce24 /cmd/acme/main.go
parent540d42db384bc1f0714ce859fbc862e3a09762d6 (diff)
Move renew check into clousure
Diffstat (limited to 'cmd/acme/main.go')
-rw-r--r--cmd/acme/main.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/acme/main.go b/cmd/acme/main.go
index ffa74c9..67838f7 100644
--- a/cmd/acme/main.go
+++ b/cmd/acme/main.go
@@ -4,6 +4,7 @@ package main
import (
"flag"
"log"
+ "time"
"dim13.org/acme"
)
@@ -90,7 +91,13 @@ func requestCert(prov *acme.Provider, acc *acme.Account, d domain) error {
return err
}
}
- if !d.needsRenew(c.Leaf) && !*forceRenew {
+ needsRenew := func() bool {
+ if c.Leaf == nil {
+ return true
+ }
+ return time.Now().Add(d.Gracetime).After(c.Leaf.NotAfter)
+ }
+ if !needsRenew() && !*forceRenew {
log.Println("skip valid until", c.Leaf.NotAfter)
return nil
}