Skip to content

Commit 6710e76

Browse files
committed
OCPBUGS-45290: Block Upgrades for SHA1 Intermediate Certs
Previously, upgrades were blocked for SHA1 leaf certificates, while SHA1 root CA certificates were allowed. However, SHA1 intermediate certificates, are also rejected in 4.16. This update adds the `UnservableInFutureVersions` condition when a route's `spec.tls.caCertificate` includes an intermediate certificate with SHA1. This blocks upgrades using the admin-ack mechanism.
1 parent dc38fbd commit 6710e76

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pkg/router/routeapihelpers/validation.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,26 @@ func UpgradeRouteValidation(route *routev1.Route) field.ErrorList {
411411
result = append(result, field.Invalid(tlsCertFieldPath, "redacted certificate data", message))
412412
}
413413
}
414+
415+
if len(tlsConfig.CACertificate) > 0 {
416+
certs, err := cert.ParseCertsPEM([]byte(tlsConfig.CACertificate))
417+
if err != nil {
418+
// Handling cert parsing errors, like malformed or invalid certs, isn't necessary here,
419+
// as the ExtendedValidator plugin is responsible for handling these errors.
420+
return result
421+
}
422+
423+
for _, cert := range certs {
424+
// Only intermediate CAs are affected, not root CAs.
425+
if cert.IsCA && cert.BasicConstraintsValid && cert.Issuer.CommonName != cert.Subject.CommonName {
426+
if cert.SignatureAlgorithm == x509.SHA1WithRSA || cert.SignatureAlgorithm == x509.ECDSAWithSHA1 {
427+
tlsCertFieldPath := field.NewPath("spec").Child("tls").Child("caCertificate")
428+
message := "OpenShift 4.16 does not support intermediate CA certificates using SHA1 signature algorithms. This route will be rejected in OpenShift 4.16. To maintain functionality in OpenShift 4.16, generate a new certificate using a supported signature algorithm such as SHA256, SHA384, or SHA512, and update this route accordingly."
429+
result = append(result, field.Invalid(tlsCertFieldPath, "redacted certificate data", message))
430+
}
431+
}
432+
}
433+
}
434+
414435
return result
415436
}

0 commit comments

Comments
 (0)