Skip to content

Commit 4ff3118

Browse files
committed
clarify terminology for gateway TLS
1 parent d28cd59 commit 4ff3118

File tree

1 file changed

+52
-98
lines changed

1 file changed

+52
-98
lines changed

geps/gep-2907/index.md

Lines changed: 52 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ This GEP aims to define high level TLS terminology and structure within Gateway
88
API to ensure that all our independent proposals related to TLS result in a
99
coherent set of APIs. This will result in some adjustments to provisional and
1010
experimental TLS-related GEPs, specifically [BackendTLSPolicy](../gep-1897/index.md)
11-
and [Client Certificate Verification](../gep-91/index.md).
1211

1312
## Goals
1413
* Define high-level terminology for how we refer to TLS in Gateway API.
15-
* Define top level fields where TLS configuration can live.
14+
* Define top level fields where TLS and mutual TLS configuration can live.
1615

1716
## Non-Goals
1817
* Add or change fields directly. (This may inspire changes in other GEPs
@@ -30,29 +29,15 @@ in scope for this GEP. In the future, this GEP may be expanded to include:
3029

3130
## Introduction
3231

33-
### Where TLS could be configured
34-
We have three different places where we might want to configure TLS:
35-
36-
#### A. Gateways
37-
Config attached at this layer will apply to everything behind a single address
38-
such as a virtual IP.
32+
### TLS mode
3933

40-
#### B. Gateway Listeners
41-
Each Gateway contains multiple “Listeners”. Each HTTPS Listener in a Gateway
42-
must have a unique combination of protocol, port, and SNI (Server Name
43-
Indication). TLS configuration attached at this layer should be [isolated via
44-
SNI](../../guides/implementers.md#listener-isolation).
34+
TLS can be configured with two distinct modes:
35+
* **Passthrough**: The Gateway forwards encrypted traffic directly to the backend from the entity originating the connection (called later a client). The TLS connection is established between the client and the backend; the Gateway does not participate in the TLS handshake.
4536

46-
#### C. BackendTLSPolicy
47-
This policy allows us to attach unique TLS configuration per Backend. Depending
48-
on the organization, this policy may be owned by the application owner or the
49-
cluster operator. Note that this configuration will be used by all Gateways
50-
(potentially from different implementations) that are connecting to the backend.
37+
* **Terminate**: The Gateway acts as a man-in-the-middle, terminating the client's TLS connection and originating a separate connection to the backend when routing the traffic. Both connections can independently support TLS and mutual TLS due to their distinct TLS configurations. The Gateway's dual role as a client or server affects the placement of TLS settings needed for given connection.
5138

5239
### "Frontend" and "Backend"
53-
A guiding principle in this naming is to use consistent naming for “Downstream”
54-
(1+2) and “Upstream” (3+4), similar to Envoy. To avoid the confusion with what
55-
is upstream and downstream, Gateway API will use “Frontend” (1+2) and “Backend”
40+
A guiding principle in this naming is to use consistent naming for both TLS connections “Downstream” (1+2) and “Upstream” (3+4) handled by the Gateway (similar to Envoy). To avoid the confusion with what is upstream and downstream, Gateway API will use “Frontend” (1+2) and “Backend”
5641
(3+4).
5742

5843
* **Frontend:** The entity connecting to a Gateway, typically a client
@@ -73,43 +58,34 @@ flowchart LR
7358

7459
The above diagram depicts these four segments as edges in a graph.
7560

76-
### TLS mode
61+
#### Frontend configuration
7762

78-
TLS can be configured with two distinct modes:
63+
In the Frontend TLS connection Gateway acts as a server and presents Server certificate during TLS handshake. Client connects to the Gateway on domain basis and this is desired to configure Server certificates on the Listener.
64+
In the mutual frontend TLS Gateway needs to verify client certificates with configured CA. It was expected that CA configuration would be also defined on Listener but due to connection coalescing this solution was not secure. We decided to move client certificate validation configuration on the Gateway level and allow for per port overrides.
65+
66+
#### Backend configuration
67+
68+
In the Backend connection Gateway acts as a client. The nature of the connection (HTTP or HTTPS) is configured on the Service using BackendTLSPolicy. If BackendTLSPolicy is defined for a Service, the Gateway must establish an HTTPS connection with the backend. During the TLS handshake, the backend presents a Server certificate. The Gateway validates this certificate against a CA certificate (and optionally SANs) configured by BackendTLSPolicy.
69+
For mutual backend TLS, the Gateway's identity must be configured. This identity, a client certificate set on the Gateway object, will be presented by the Gateway. The Gateway uses the same client certificate for all backend connections originating mutual TLS.
7970

80-
* **Terminate**: the TLS connection is instantiated between the frontend and the
81-
Gateway. The connection between the Gateway and the backend is left unencrypted
82-
unless a new TLS connection between the two entities is configured via BackendTLSPolicy.
83-
* **Passthrough**: the TLS connection is instantiated between the frontend and the
84-
backend. The traffic flows through the Gateway encrypted, and the Gateway is not
85-
able to decrypt or inspect the encrypted portions of the TLS stream.
8671

8772
## Proposed Segments
88-
Note that this does not represent any form of commitment that any of these
89-
fields or concepts will exist within Gateway API. If or when they do, we propose
90-
the following naming structure:
9173

92-
### 1. Validate Client Certificate provided by Frontend
74+
75+
### 1. Gateway level configuration
76+
77+
Gateway-level configurations are required for both Frontend and Backend connections. We propose a top-level GatewayTLSConfig that is divided into independent Backend and Frontend configurations.
9378

9479
| Proposed Placement | Name | Status |
9580
|-|-|-|
96-
| Gateway Listener | `Listener.TLS.FrontendValidation` | Proposed |
81+
| Gateway | `Gateway.TLS.Frontend` | Proposed |
82+
| Gateway | `Gateway.TLS.Backend` | Proposed |
9783

9884
#### Rationale
99-
Use FrontendValidation to leave room for concepts like trust anchors and trust
100-
domains. Anything not strictly tied to validation would belong to Listener.TLS
101-
which is now reserved exclusively for “Frontend” TLS configuration (1+2).
102-
103-
#### Why Not Frontend.Validation?
104-
Part of the idea behind this GEP is that Listener.TLS is really entirely focused
105-
on 1+2 - the bits of TLS between frontend and Gateway. That means that if we
106-
were to add any additional TLS configuration in the Listener.TLS struct, it
107-
would tied to that limited scope, and thus we don't really need a separate
108-
Frontend struct.
85+
From the security point of view both TLS configurations require a Gateway level field. The configurations are independent and can coexist.
10986

110-
One could make an argument that Listener.TLS.Validation should be the field name
111-
here to avoid any ambiguity, but in this specific context, we think that it's
112-
probably helpful to specifically spell out frontend.
87+
#### Why Not Listener.Frontend?
88+
Due to connection coalescing, the client certificate validation for the frontend was moved to a Gateway level field to address security concerns. [GEP-91 Update PR](https://github.com/kubernetes-sigs/gateway-api/pull/3942)
11389

11490
#### Why Not FrontendTLSPolicy?
11591
It could be reasonable to try to mirror BackendTLSPolicy for Frontend TLS. As we
@@ -129,7 +105,7 @@ We don't think either of those reasons really apply to frontend TLS. Instead,
129105
frontend TLS could theoretically be configured either for an entire Gateway, or
130106
a specific Gateway listener. Given that many implementations already support
131107
distinguishing this config per SNI, it seems to make sense to start with
132-
listener level attachment. We think that the persona that would be responsible
108+
Listener level attachment. We think that the persona that would be responsible
133109
for a Gateway is not sufficiently different than the persona that would be
134110
responsible for frontend TLS, so the current proposal is likely the best option
135111
available to us.
@@ -145,17 +121,30 @@ This is already finalized in the API and so we're stuck with this name. In
145121
hindsight a name that was more clearly tied to frontend TLS would have been
146122
ideal here.
147123

148-
### 3. Configure Client Certificate that Gateway should use to connect to Backend
124+
### 3. Configure Client Certificate Validation for Frontend
125+
126+
Client certificate validation will reside at the Gateway level. This configuration will be
127+
either applied globally to all Listeners in the Gateway or can be overridden on a per-port basis.
149128

150129
| Proposed Placement | Name | Status |
151130
|-|-|-|
152-
| Gateway | `Gateway.Spec.BackendTLS.ClientCertificateRef` | Not Proposed |
153-
| BackendTLSPolicy | `BackendTLSPolicy.Spec.ClientCertificateRef` | Not Proposed |
131+
| Gateway | `Gateway.TLS.Frontend.Default.Validation` | Proposed |
132+
| Gateway | `Gateway.TLS.Frontend.PerPort` | Proposed |
154133

155134
#### Rationale
156-
It's not yet obvious which of the above options are preferable, but a case could
157-
be made for either or both. If we add a `BackendTLS` struct to Gateway it would
158-
leave room for concepts like TLS version, ALPN, cipher suites, etc.
135+
Gateway level configuration for client certificate validation was chosen due to security issue.
136+
137+
#### Why per port override
138+
HTTPS connection can be reused between multiple Listeners sharing the same port. This might lead to bypassing client certificate validation configuration for a given Listener becasue new TLS handshake will not be triggered for different hostname.
139+
140+
### 4. Configure Client Certificate that Gateway should use to connect to Backend
141+
142+
| Proposed Placement | Name | Status |
143+
|-|-|-|
144+
| Gateway | `Gateway.Spec.TLS.Backend.ClientCertificateRef` | Proposed |
145+
146+
#### Rationale
147+
Client certificate is part of Gateway identity and should not be overriden per backend.
159148

160149
#### Why Not Listener level to match FrontendValidation?
161150
In general, we'd expect this identity to represent a Gateway as a whole, and
@@ -167,7 +156,7 @@ use when connecting to a backend, it should likely either be tied directly to
167156
the Gateway or Backend, but the Listener is not particularly relevant in this
168157
context.
169158

170-
### 4. Validate Server Certificate that is provided by Backend
159+
### 5. Validate Server Certificate that is provided by Backend
171160
| Proposed Placement | Name | Status |
172161
|-|-|-|
173162
| Gateway | `Gateway.Spec.BackendTLS.Validation` | Not Proposed |
@@ -179,42 +168,7 @@ already clearly backend-focused, config like TLS Version, ALPN, and cipher
179168
suites, could live at the same level without confusion. It's also plausible that
180169
some Gateways may want to express Gateway-wide CAs that are trusted.
181170

182-
#### Why BackendTLS on Gateways?
183-
Although this GEP is intentionally not committing to adding new fields or
184-
features, it's possible that at some point in the future we may want to have
185-
some kind of Backend TLS config at the Gateway level. For example, it may be
186-
useful to configure a set of CAs that a Gateway trusts or a client cert that a
187-
Gateway should use to connect to all backends. If this existed, there would
188-
likely be some overlap in config with BackendTLSPolicy, and if a future GEP
189-
proposed this, it would need to include how overlapping config should be
190-
handled.
191-
192-
#### Why the inconsistency between Frontend and Backend TLS config on Gateways?
193-
If we were to populate all the possible fields described in this GEP, we'd end
194-
up with the following config on Gateways:
195-
196-
```
197-
Gateway.Spec.Listeners.TLS.FrontendValidation
198-
Gateway.Spec.Listeners.TLS
199-
Gateway.Spec.BackendTLS.ClientCertificateRef
200-
Gateway.Spec.BackendTLS.Validation
201-
```
202-
203-
This is all tied to the need to provide backwards compatibility with the TLS
204-
config that is already GA on Listeners (`Listener.TLS`). If we were naming that
205-
field today with the broader vision of TLS configuration throughout Gateway API
206-
we would almost certainly choose a more descriptive name that was more clearly
207-
tied to Frontend TLS. Unfortunately we're too late to change that name, but we
208-
can try to make the rest of the terminology clearly tied to frontend or backend
209-
TLS.
210-
211-
One [suggestion by @candita](https://github.com/kubernetes-sigs/gateway-api/pull/2910#discussion_r1552534017)
212-
would be to introduce a Listener like resource for BackendTLS, resulting in a
213-
more consistent naming scheme within Gateway TLS configuration. Although it's
214-
not yet clear if we need this additional layer, we should reconsider it as we're
215-
further developing Backend TLS.
216-
217-
### 5. Configure TLS mode
171+
### 6. Configure TLS mode
218172

219173
| Proposed Placement | Name | Status |
220174
|-|-|-|
@@ -236,8 +190,8 @@ does not need to be provided, as the TLS termination is handled by the backend.
236190

237191
## Routes and TLS
238192

239-
Multiple routes can be attached to listeners specifying TLS configuration. This section
240-
intends to clearly state how and when Routes can attach to listeners with TLS configuration.
193+
Multiple routes can be attached to Listeners specifying TLS configuration. This section
194+
intends to clearly state how and when Routes can attach to Listeners with TLS configuration.
241195

242196
### Context
243197

@@ -265,12 +219,12 @@ with the compatible protocol.
265219
|-----------|---------|---------------|----------------|
266220
| HTTP | `HTTPRoute`/`GRPCRoute` | no | no |
267221
| HTTPS | `HTTPRoute`/`GRPCRoute` | yes | no |
268-
| TLS | `TLSRoute` | yes | yes |
222+
| TLS | `TLSRoute` | yes | yes |
269223
| TCP | `TCPRoute` | yes | no |
270224
| UDP | `UDPRoute` | no | no |
271225

272226
> [!NOTE]
273-
> When the traffic is routed to the backend via a listener configured with TLS `Passthrough`
274-
> and a compatible route, the packets are left untouched by the gateway. In order to
275-
> terminate the TLS connection to the gateway and forward the traffic unencrypted to the backend,
276-
> a listener configured with TLS `Terminate` and a compatible route must be used.
227+
> When the traffic is routed to the backend via a Listener configured with TLS `Passthrough`
228+
> and a compatible route, the packets are left untouched by the Gateway. In order to
229+
> terminate the TLS connection to the Gateway and forward the traffic unencrypted to the backend,
230+
> a Listener configured with TLS `Terminate` and a compatible route must be used.

0 commit comments

Comments
 (0)