mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 14:26:58 +00:00
remove unnecessary stuff
This commit is contained in:
parent
e320f34ec1
commit
5954ca83c5
1 changed files with 1 additions and 10 deletions
|
@ -112,19 +112,10 @@ func TLSConfig(mainDomainSuffix string,
|
||||||
}
|
}
|
||||||
|
|
||||||
if tlsCertificate, ok := keyCache.Get(domain); ok {
|
if tlsCertificate, ok := keyCache.Get(domain); ok {
|
||||||
if tlsCertificate.Leaf == nil {
|
if tlsCertificate.Leaf.NotAfter.Before(time.Now().Add(7 * 24 * time.Hour)) {
|
||||||
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 cert is up for renewal remove it from the cache
|
// if cert is up for renewal remove it from the cache
|
||||||
keyCache.Remove(domain)
|
keyCache.Remove(domain)
|
||||||
} else {
|
} else {
|
||||||
log.Error().Msg("Cert is not expired")
|
|
||||||
// we can use an existing certificate object
|
// we can use an existing certificate object
|
||||||
return tlsCertificate, nil
|
return tlsCertificate, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue