From 767868108a78b0c62b6613dba22e81b9134739b2 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 18 Mar 2016 19:35:41 +0100 Subject: wip --- cmd/batch/files.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmd/batch/files.go') 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) -- cgit v1.2.3