aboutsummaryrefslogtreecommitdiff
path: root/cmd
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
parent540d42db384bc1f0714ce859fbc862e3a09762d6 (diff)
Move renew check into clousure
Diffstat (limited to 'cmd')
-rw-r--r--cmd/acme/config.go8
-rw-r--r--cmd/acme/main.go9
2 files changed, 8 insertions, 9 deletions
diff --git a/cmd/acme/config.go b/cmd/acme/config.go
index 36d5f46..bec6a19 100644
--- a/cmd/acme/config.go
+++ b/cmd/acme/config.go
@@ -1,7 +1,6 @@
package main
import (
- "crypto/x509"
"errors"
"io/ioutil"
"os/user"
@@ -170,10 +169,3 @@ func checkWWW(altnames []string) []string {
}
return altnames
}
-
-func (d domain) needsRenew(cert *x509.Certificate) bool {
- if cert == nil {
- return true
- }
- return time.Now().Add(d.Gracetime).After(cert.NotAfter)
-}
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
}