remove unnecessary stuff

This commit is contained in:
crapStone 2024-04-30 23:30:30 +02:00 committed by crapStone
parent e320f34ec1
commit 5954ca83c5
1 changed files with 1 additions and 10 deletions

View File

@ -112,19 +112,10 @@ func TLSConfig(mainDomainSuffix string,
}
if tlsCertificate, ok := keyCache.Get(domain); ok {
if tlsCertificate.Leaf == nil {
log.Error().Msg("Leaf is nil")
tlsCertificate.Leaf, err = x509.ParseCertificate(tlsCertificate.Certificate[0])
if err != nil {
return nil, fmt.Errorf("error parsing leaf tlsCert: %w", err)
}
}
// if Leaf == nil the certificate can't be in the cache for a long time so we just ignore it
if tlsCertificate.Leaf != nil && tlsCertificate.Leaf.NotAfter.Before(time.Now().Add(7*24*time.Hour)) {
if tlsCertificate.Leaf.NotAfter.Before(time.Now().Add(7 * 24 * time.Hour)) {
// if cert is up for renewal remove it from the cache
keyCache.Remove(domain)
} else {
log.Error().Msg("Cert is not expired")
// we can use an existing certificate object
return tlsCertificate, nil
}