summaryrefslogtreecommitdiff
path: root/diff.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-11-18 03:23:25 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-11-18 03:23:25 -0500
commit89fa60bdf5ed6bd729f4d7931c9603e896d38665 (patch)
treeb13004ac9c45976ae340e6dba13774dac1ea4abb /diff.go
parentc4f6d3489ef91c539ba88e372635e4d0d87e6ad2 (diff)
more
Diffstat (limited to 'diff.go')
-rw-r--r--diff.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/diff.go b/diff.go
index 24fa228..25c9028 100644
--- a/diff.go
+++ b/diff.go
@@ -80,6 +80,13 @@ func keys(m map[string]*x509.Certificate) []string {
return ret
}
+func fmtCert(cert *x509.Certificate) string {
+ return fmt.Sprintf("%s %s %s",
+ cert.Subject.CommonName,
+ cert.NotBefore.Format("2006-01-02 15:04:05 MST(-07)"),
+ cert.NotAfter.Format("2006-01-02 15:04:05 MST(-07)"))
+}
+
func main() {
if len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, "Usage: %s TLS-file crt.sh-file\n", os.Args[0])
@@ -97,12 +104,12 @@ func main() {
certTLS := certsTLS[host]
certCrtSh, okCrtSh := certsCrtSh[host]
if !okCrtSh {
- fmt.Printf("-%s %s\n", host, certTLS.NotBefore.Format("2006-01-02 15:04:05 MST(-07)"))
+ fmt.Printf("-%s %s\n", host, fmtCert(certTLS))
} else if !certTLS.Equal(certCrtSh) {
- fmt.Printf("-%s %s\n", host, certTLS.NotBefore.Format("2006-01-02 15:04:05 MST(-07)"))
- fmt.Printf("+%s %s\n", host, certCrtSh.NotBefore.Format("2006-01-02 15:04:05 MST(-07)"))
+ fmt.Printf("-%s %s\n", host, fmtCert(certTLS))
+ fmt.Printf("+%s %s\n", host, fmtCert(certCrtSh))
} else {
- fmt.Printf(" %s %s\n", host, certTLS.NotBefore.Format("2006-01-02 15:04:05 MST(-07)"))
+ fmt.Printf(" %s %s\n", host, fmtCert(certTLS))
}
}
}