Skip to content

Commit

Permalink
pkg/asset/ignition/bootstrap: exit loop if pem.Decode() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jhixson74 committed Oct 28, 2020
1 parent 879e9bb commit a676b27
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Expand Up @@ -579,23 +579,22 @@ func warnIfCertificatesExpired(config *igntypes.Config) {
data := decoded.Data
for {
block, rest := pem.Decode(data)
if block != nil {
cert, err := x509.ParseCertificate(block.Bytes)
if err == nil {
if time.Now().UTC().After(cert.NotAfter) {
logrus.Warnf("Bootstrap Ignition-Config Certificate %s expired at %s.", path.Base(file.Path), cert.NotAfter.Format(time.RFC3339))
expiredCerts++
}
} else {
logrus.Debugf("Unable to parse certificate %s: %s", fileName, err.Error())
break
}
if block == nil {
break
}
if len(rest) > 0 {
data = rest

cert, err := x509.ParseCertificate(block.Bytes)
if err == nil {
if time.Now().UTC().After(cert.NotAfter) {
logrus.Warnf("Bootstrap Ignition-Config Certificate %s expired at %s.", path.Base(file.Path), cert.NotAfter.Format(time.RFC3339))
expiredCerts++
}
} else {
logrus.Debugf("Unable to parse certificate %s: %s", fileName, err.Error())
break
}

data = rest
}
}
}
Expand Down

0 comments on commit a676b27

Please sign in to comment.