Skip to content

Commit 3a55840

Browse files
Merge pull request #9225 from barbacbd/CORS-3633
CORS-3633: Fail the install when there are expired certs
2 parents 22b442c + d7a7dc0 commit 3a55840

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/asset/ignition/bootstrap/common.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,16 @@ func (a *Common) load(f asset.FileFetcher, filename string) (found bool, err err
709709
}
710710

711711
a.File, a.Config = file, config
712-
warnIfCertificatesExpired(a.Config)
713-
return true, nil
712+
err = warnIfCertificatesExpired(a.Config)
713+
if err != nil {
714+
logrus.Warnf("Please regenerate ignition configuration files in a new directory.")
715+
}
716+
717+
return true, err
714718
}
715719

716720
// warnIfCertificatesExpired checks for expired certificates and warns if so
717-
func warnIfCertificatesExpired(config *igntypes.Config) {
721+
func warnIfCertificatesExpired(config *igntypes.Config) error {
718722
expiredCerts := 0
719723
for _, file := range config.Storage.Files {
720724
if filepath.Ext(file.Path) == ".crt" && file.Contents.Source != nil {
@@ -734,7 +738,7 @@ func warnIfCertificatesExpired(config *igntypes.Config) {
734738
cert, err := x509.ParseCertificate(block.Bytes)
735739
if err == nil {
736740
if time.Now().UTC().After(cert.NotAfter) {
737-
logrus.Warnf("Bootstrap Ignition-Config Certificate %s expired at %s.", path.Base(file.Path), cert.NotAfter.Format(time.RFC3339))
741+
logrus.Errorf("Bootstrap Ignition-Config Certificate %s expired at %s.", path.Base(file.Path), cert.NotAfter.Format(time.RFC3339))
738742
expiredCerts++
739743
}
740744
} else {
@@ -748,6 +752,7 @@ func warnIfCertificatesExpired(config *igntypes.Config) {
748752
}
749753

750754
if expiredCerts > 0 {
751-
logrus.Warnf("Bootstrap Ignition-Config: %d certificates expired. Installation attempts with the created Ignition-Configs will possibly fail.", expiredCerts)
755+
return fmt.Errorf("%d certificates expired", expiredCerts)
752756
}
757+
return nil
753758
}

0 commit comments

Comments
 (0)