Skip to content

Commit 2d4b116

Browse files
Check the certificate expiration date
1 parent 2f3282d commit 2d4b116

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

certificates/certificates.go

+11
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,14 @@ func DeleteCertificates(certDir *paths.Path) {
267267
certDir.Join("cert.pem").Remove()
268268
certDir.Join("cert.cer").Remove()
269269
}
270+
271+
// IsExpired checks if a certificate is expired
272+
func IsExpired(cert []byte) bool {
273+
pCert, err := x509.ParseCertificate(cert)
274+
if err != nil {
275+
log.Error(err.Error())
276+
os.Exit(1)
277+
}
278+
// we could add an offset
279+
return pCert.NotAfter.Before(time.Now())
280+
}

0 commit comments

Comments
 (0)