Skip to content

Commit 01b2ebf

Browse files
committed
fix backend satus
Signed-off-by: Huabing Zhao <[email protected]>
1 parent 7de6d74 commit 01b2ebf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/gatewayapi/backend.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ func validateBackend(backend *egv1a1.Backend, backendTLSPolicies []*gwapiv1.Back
8787

8888
// validateBackendTLSSettings validates CACert is specified if InsecureSkipVerify is false
8989
func validateBackendTLSSettings(backend *egv1a1.Backend, backendTLSPolicies []*gwapiv1.BackendTLSPolicy) status.Error {
90-
if backend.Spec.TLS != nil && !ptr.Deref(backend.Spec.TLS.InsecureSkipVerify, false) {
90+
if backend.Spec.TLS == nil {
91+
return nil
92+
}
93+
94+
if !ptr.Deref(backend.Spec.TLS.InsecureSkipVerify, false) {
9195
var (
9296
backendTLSHasCACerts bool
9397
backendTLSPoliciesHasCACerts bool
@@ -152,6 +156,16 @@ func validateBackendTLSSettings(backend *egv1a1.Backend, backendTLSPolicies []*g
152156
}
153157
}
154158
}
159+
160+
if backend.Spec.TLS.BackendTLSConfig != nil && backend.Spec.TLS.ClientCertificateRef != nil {
161+
ns := string(ptr.Deref(backend.Spec.TLS.ClientCertificateRef.Namespace, "default"))
162+
if ns != backend.Namespace {
163+
return status.NewRouteStatusError(
164+
fmt.Errorf("clientCertificateRef Secret is not located in the same namespace as Backend. Secret namespace: %s does not match Backend namespace: %s", ns, backend.Namespace),
165+
status.RouteReasonInvalidBackendRef,
166+
)
167+
}
168+
}
155169
return nil
156170
}
157171

0 commit comments

Comments
 (0)