aboutsummaryrefslogtreecommitdiff
path: root/cmd/batch/files.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-18 19:35:41 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-18 19:35:41 +0100
commit767868108a78b0c62b6613dba22e81b9134739b2 (patch)
tree456804a8348e184b47dff54ebf5b18da9e4d1ad8 /cmd/batch/files.go
parent40a9ef230ee6112e6e8bf5981a4e18a17f34e307 (diff)
wip
Diffstat (limited to 'cmd/batch/files.go')
-rw-r--r--cmd/batch/files.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/batch/files.go b/cmd/batch/files.go
index fee7a1a..474d0ff 100644
--- a/cmd/batch/files.go
+++ b/cmd/batch/files.go
@@ -3,11 +3,12 @@ package main
import (
"crypto/tls"
"crypto/x509"
+ "fmt"
"io"
- "log"
"os"
"path"
"path/filepath"
+ "time"
"dim13.org/acme"
)
@@ -18,6 +19,14 @@ type Cert struct {
crtFile string
}
+func (c Cert) String() string {
+ return fmt.Sprint(c.Leaf.DNSNames, " valid until ", c.Leaf.NotAfter)
+}
+
+func (c Cert) IsValid(grace time.Duration) bool {
+ return time.Now().Add(grace).Before(c.Leaf.NotAfter)
+}
+
func loadFiles(crtFile, keyFile string) (Cert, error) {
crt, err := tls.LoadX509KeyPair(crtFile, keyFile)
if err != nil {
@@ -67,7 +76,6 @@ func scanFiles(dir string) ([]Cert, error) {
c := filepath.Join(dir, "certs", filepath.Base(k[:len(k)-4])+".pem")
crt, err := loadFiles(c, k)
if err != nil {
- log.Println(err)
continue
}
certs = append(certs, crt)