Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bff5c3e

Browse files
committedApr 24, 2024
Check the certificate expiration date
1 parent 3e5f9e6 commit bff5c3e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎certificates/certificates.go

Lines changed: 10 additions & 0 deletions
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)
Please sign in to comment.