Skip to content

Commit 25b2e74

Browse files
committed
Loosening TLS validation to enable indirect TLS config
1 parent da26d60 commit 25b2e74

File tree

6 files changed

+161
-83
lines changed

6 files changed

+161
-83
lines changed

apis/v1/gateway_types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ type GatewaySpec struct {
186186
// +listMapKey=name
187187
// +kubebuilder:validation:MinItems=1
188188
// +kubebuilder:validation:MaxItems=64
189-
// +kubebuilder:validation:XValidation:message="tls must be specified for protocols ['HTTPS', 'TLS']",rule="self.all(l, l.protocol in ['HTTPS', 'TLS'] ? has(l.tls) : true)"
190189
// +kubebuilder:validation:XValidation:message="tls must not be specified for protocols ['HTTP', 'TCP', 'UDP']",rule="self.all(l, l.protocol in ['HTTP', 'TCP', 'UDP'] ? !has(l.tls) : true)"
191190
// +kubebuilder:validation:XValidation:message="tls mode must be Terminate for protocol HTTPS",rule="self.all(l, (l.protocol == 'HTTPS' && has(l.tls)) ? (l.tls.mode == '' || l.tls.mode == 'Terminate') : true)"
192191
// +kubebuilder:validation:XValidation:message="hostname must not be specified for protocols ['TCP', 'UDP']",rule="self.all(l, l.protocol in ['TCP', 'UDP'] ? (!has(l.hostname) || l.hostname == '') : true)"
@@ -375,19 +374,18 @@ const (
375374
)
376375

377376
// GatewayTLSConfig describes a TLS configuration.
378-
//
379-
// +kubebuilder:validation:XValidation:message="certificateRefs must be specified when TLSModeType is Terminate",rule="self.mode == 'Terminate' ? size(self.certificateRefs) > 0 : true"
380377
type GatewayTLSConfig struct {
381378
// Mode defines the TLS behavior for the TLS session initiated by the client.
382379
// There are two possible modes:
383380
//
384-
// - Terminate: The TLS session between the downstream client
385-
// and the Gateway is terminated at the Gateway. This mode requires
386-
// certificateRefs to be set and contain at least one element.
381+
// - Terminate: The TLS session between the downstream client and the
382+
// Gateway is terminated at the Gateway. This mode requires certificates
383+
// to be specified in some way, such as populating the certificateRefs
384+
// field.
387385
// - Passthrough: The TLS session is NOT terminated by the Gateway. This
388386
// implies that the Gateway can't decipher the TLS stream except for
389-
// the ClientHello message of the TLS protocol.
390-
// CertificateRefs field is ignored in this mode.
387+
// the ClientHello message of the TLS protocol. The certificateRefs field
388+
// is ignored in this mode.
391389
//
392390
// Support: Core
393391
//
@@ -701,8 +699,10 @@ const (
701699
// true.
702700
GatewayReasonProgrammed GatewayConditionReason = "Programmed"
703701

704-
// This reason is used with the "Programmed" and "Accepted" conditions when the Gateway is
705-
// syntactically or semantically invalid.
702+
// This reason is used with the "Programmed" and "Accepted" conditions when
703+
// the Gateway is syntactically or semantically invalid. For example, this
704+
// could include unspecified TLS configuration, or some unrecognized or
705+
// invalid values in the TLS configuration.
706706
GatewayReasonInvalid GatewayConditionReason = "Invalid"
707707

708708
// This reason is used with the "Programmed" condition when the

config/crd/experimental/gateway.networking.k8s.io_gateways.yaml

Lines changed: 12 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/standard/gateway.networking.k8s.io_gateways.yaml

Lines changed: 12 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/test/cel/gateway_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ func TestValidateGateway(t *testing.T) {
125125
},
126126
}
127127
},
128-
wantErrors: []string{"tls must be specified for protocols ['HTTPS', 'TLS']"},
129128
},
130129
{
131130
desc: "tls config not set with tls protocol",
@@ -138,7 +137,6 @@ func TestValidateGateway(t *testing.T) {
138137
},
139138
}
140139
},
141-
wantErrors: []string{"tls must be specified for protocols ['HTTPS', 'TLS']"},
142140
},
143141
{
144142
desc: "tls config not set with http protocol",
@@ -221,7 +219,6 @@ func TestValidateGateway(t *testing.T) {
221219
},
222220
}
223221
},
224-
wantErrors: []string{"certificateRefs must be specified when TLSModeType is Terminate"},
225222
},
226223
{
227224
desc: "certificateRefs not set with tls protocol and TLS terminate mode",
@@ -238,7 +235,6 @@ func TestValidateGateway(t *testing.T) {
238235
},
239236
}
240237
},
241-
wantErrors: []string{"certificateRefs must be specified when TLSModeType is Terminate"},
242238
},
243239
{
244240
desc: "certificateRefs set with tls protocol and TLS terminate mode",

0 commit comments

Comments
 (0)