chore: reduce azure CA cert validity check period to 2 months (#12788)

Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
Danny Kopping 2024-03-28 11:17:02 +02:00 committed by GitHub
parent 0288e73e9b
commit d734f3fb74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -53,15 +53,17 @@ func TestValidate(t *testing.T) {
func TestExpiresSoon(t *testing.T) {
t.Parallel()
const threshold = 2
for _, c := range azureidentity.Certificates {
block, rest := pem.Decode([]byte(c))
require.Zero(t, len(rest))
cert, err := x509.ParseCertificate(block.Bytes)
require.NoError(t, err)
expiresSoon := cert.NotAfter.Before(time.Now().AddDate(0, 3, 0))
expiresSoon := cert.NotAfter.Before(time.Now().AddDate(0, threshold, 0))
if expiresSoon {
t.Errorf("certificate expires within 6 months %s: %s", cert.NotAfter, cert.Subject.CommonName)
t.Errorf("certificate expires within %d months %s: %s", threshold, cert.NotAfter, cert.Subject.CommonName)
} else {
url := "no issuing url"
if len(cert.IssuingCertificateURL) > 0 {