From 6ac18619cf881074fe6edcc79ab62c9c85da60b9 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 5 Nov 2024 03:29:45 -0800 Subject: [PATCH] Only warn if less than 28 days to cert expires (#5077) Fixes #5076 as much as reasonable. --- cmd/client-s3.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index daeb3ea7..1fd4fdab 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -196,7 +196,8 @@ func (n notifyExpiringTLS) RoundTrip(req *http.Request) (res *http.Response, err cert := res.TLS.PeerCertificates[0] // leaf certificate validityDur := cert.NotAfter.Sub(cert.NotBefore) - if time.Since(cert.NotBefore) > time.Duration(0.9*float64(validityDur)) { + // Warn if less than 10% of time left and it is less than 28 days. + if time.Until(cert.NotAfter) < time.Duration(min(0.1*float64(validityDur), 28*24*float64(time.Hour))) { globalExpiringCerts.Store(req.Host, cert.NotAfter) }