rotate wrangler cert

This commit is contained in:
galal-hussein
2019-10-08 23:56:00 +02:00
parent e2ac9e2c19
commit 583d996366
4 changed files with 35 additions and 4 deletions

View File

@@ -36,6 +36,8 @@ import (
"path"
"strings"
"time"
"github.com/sirupsen/logrus"
)
const (
@@ -267,3 +269,14 @@ func ipsToStrings(ips []net.IP) []string {
}
return ss
}
// IsCertExpired checks if the certificate about to expire
func IsCertExpired(cert *x509.Certificate) bool {
expirationDate := cert.NotAfter
diffDays := expirationDate.Sub(time.Now()).Hours() / 24.0
if diffDays <= 90 {
logrus.Infof("certificate will expire in %f days", diffDays)
return true
}
return false
}