Skip to content

Commit

Permalink
Show if certificate is not yet/no longer valid in show-cert tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Jan 27, 2019
1 parent ee92133 commit f82c9fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/show-cert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"io/ioutil"
"os"
"sort"
"time"

"github.com/Symantec/Dominator/lib/format"
"github.com/Symantec/Dominator/lib/x509util"
)

Expand Down Expand Up @@ -37,6 +39,14 @@ func showCert(filename string) {
fmt.Fprintf(os.Stderr, "Unable to parse certificate: %s\n", err)
return
}
now := time.Now()
if notYet := cert.NotBefore.Sub(now); notYet > 0 {
fmt.Fprintf(os.Stderr, " Will not be valid for %s\n",
format.Duration(notYet))
}
if expired := now.Sub(cert.NotAfter); expired > 0 {
fmt.Fprintf(os.Stderr, " Expired %s ago\n", format.Duration(expired))
}
username, err := x509util.GetUsername(cert)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to get username: %s\n", err)
Expand Down

0 comments on commit f82c9fb

Please sign in to comment.