@@ -602,7 +602,7 @@ func (ed *EndpointDetail) CreateRoute(
602602 certSecret := & k8s_corev1.Secret {}
603603
604604 // if a custom cert secret was provided, check if it exist
605- // and has the required cert, key and cacert
605+ // and has the required cert and key ( cacert optional)
606606 // Right now there is no check if certificate is valid for
607607 // the hostname of the route. If the referenced secret is
608608 // there and has the required files it is just being used.
@@ -616,13 +616,9 @@ func (ed *EndpointDetail) CreateRoute(
616616 return ctrl.Result {}, err
617617 }
618618
619- // check if secret has the expected entries tls.crt, tls.key and ca.crt
620- if certSecret != nil {
621- for _ , key := range []string {"tls.crt" , "tls.key" , "ca.crt" } {
622- if _ , exist := certSecret .Data [key ]; ! exist {
623- return ctrl.Result {}, fmt .Errorf ("certificate secret %s does not provide %s" , * ed .Route .TLS .SecretName , key )
624- }
625- }
619+ // check the secret has the required tls.crt and tls.key entries
620+ if err := validateRouteCertSecret (certSecret , * ed .Route .TLS .SecretName ); err != nil {
621+ return ctrl.Result {}, err
626622 }
627623 }
628624
@@ -659,9 +655,13 @@ func (ed *EndpointDetail) CreateRoute(
659655 Termination : routev1 .TLSTerminationEdge ,
660656 Certificate : string (certSecret .Data [tls .CertKey ]),
661657 Key : string (certSecret .Data [tls .PrivateKey ]),
662- CACertificate : string (certSecret .Data [tls .CAKey ]),
663658 InsecureEdgeTerminationPolicy : routev1 .InsecureEdgeTerminationPolicyRedirect ,
664659 }
660+ // ca.crt is optional (absent for ACME-issued certs); only set the
661+ // route CACertificate when the secret actually provides it.
662+ if caCert , ok := certSecret .Data [tls .CAKey ]; ok {
663+ tlsConfig .CACertificate = string (caCert )
664+ }
665665
666666 // for internal TLS (TLSE) use routev1.TLSTerminationReencrypt
667667 if ed .Service .TLS .Enabled && (ed .Service .TLS .SecretName != nil || hasCertInOverrideSpec (ed .Route .OverrideSpec )) {
@@ -872,6 +872,23 @@ func hasCertInOverrideSpec(overrideSpec route.OverrideSpec) bool {
872872 overrideSpec .Spec .TLS .Key != ""
873873}
874874
875+ // validateRouteCertSecret ensures a user-provided route TLS secret contains the
876+ // required tls.crt and tls.key entries. ca.crt is intentionally not required:
877+ // certificates issued by an ACME issuer (e.g. Let's Encrypt) do not populate
878+ // ca.crt, and the issuing chain is delivered via tls.crt instead. ca.crt is only
879+ // needed to advertise a custom CA on the route, which is optional.
880+ func validateRouteCertSecret (certSecret * k8s_corev1.Secret , secretName string ) error {
881+ if certSecret == nil {
882+ return nil
883+ }
884+ for _ , key := range []string {tls .CertKey , tls .PrivateKey } {
885+ if _ , exist := certSecret .Data [key ]; ! exist {
886+ return fmt .Errorf ("certificate secret %s does not provide %s" , secretName , key )
887+ }
888+ }
889+ return nil
890+ }
891+
875892func serviceExists (route string , services * k8s_corev1.ServiceList ) bool {
876893 for _ , svc := range services .Items {
877894 if svc .Name == route {
0 commit comments