Skip to content

Commit 34374ab

Browse files
Check the certificate expiration date
1 parent 28db1da commit 34374ab

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

certificates/certificates.go

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"math/big"
3131
"net"
3232
"os"
33+
"strings"
3334
"time"
3435

3536
"github.com/arduino/go-paths-helper"
@@ -267,3 +268,12 @@ func DeleteCertificates(certDir *paths.Path) {
267268
certDir.Join("cert.pem").Remove()
268269
certDir.Join("cert.cer").Remove()
269270
}
271+
272+
// IsExpired checks if a certificate is expired
273+
func IsExpired() bool {
274+
bound := time.Now().AddDate(0, 1, 0)
275+
// TODO: manage errors
276+
dateS, _ := GetExpirationDate()
277+
date, _ := time.Parse(time.DateTime, strings.ReplaceAll(dateS, " +0000", ""))
278+
return date.Before(bound)
279+
}

0 commit comments

Comments
 (0)