-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: match SNI when using TLS listeners with hostname #2942
fix: match SNI when using TLS listeners with hostname #2942
Conversation
Signed-off-by: Mike Beaumont <[email protected]>
Signed-off-by: Mike Beaumont <[email protected]>
Signed-off-by: Mike Beaumont <[email protected]>
Signed-off-by: Mike Beaumont <[email protected]>
62584b7
to
992dd33
Compare
hey @michaelbeaumont, for my understanding, is this PR is trying to solve ?
https://gateway-api.sigs.k8s.io/guides/tls/#clientserver-and-tls afaik this should be supported today |
Hey, yeah traffic is terminated properly, but if I set
|
got it makes sense, thanks for clarifying ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelbeaumont Thank you for addressing the issue! A few comments.
// +k8s:deepcopy-gen=true | ||
type TLSInspectorConfig struct { | ||
// Server names that are compared against the server names of a new connection. | ||
// Wildcard hosts are supported in the prefix form. Partial wildcards are not | ||
// supported, and values like *w.example.com are invalid. | ||
// SNIs are used only in case of TLS Passthrough. | ||
SNIs []string `json:"snis,omitempty" yaml:"snis,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving SNIs up to TLSConfig and removing TLSInspectorConfig?
TLS Inspector is an implementation detail of Envoy, so we probably don't need to expose it to ir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's already exposed as TLS.Passthrough
isn't it? I can add SNIs
directly to TLSConfig
if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for making TLSInspectorConfig
an embedded field within TLS
Line 1088 in 4d6da72
type TLS struct { |
Passthrough
field
- passthrough logic can be computed using -
isTLSPassthrough := irListener.TLS != nil && irListener.TLS.Terminate == nil
- this also eliminates the need to add
Inspector
into theTLSConfig
field, which is common to HTTPS, which uses another field (listener.Hostname
) for SNI inspection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed an update here, it changes a different part of the IR though, passthrough
-> inspector
, since that's now common between mode: Terminate
and mode: Passthrough
internal/xds/translator/testdata/out/xds-ir/tcp-route-tls-terminate.listeners.yaml
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add multiple hostnames in the gateway API translator and XDS translator tests for TLS termination? This could cover the scenario where a single listener needs to handle multiple SNIs. Thanks!
Is there any updates for this feature ? |
Signed-off-by: Mike Beaumont <[email protected]>
522da6a
to
4d6da72
Compare
@michaelbeaumont Are you still working on this? If not I can help, based on your previous work. |
Signed-off-by: Mike Beaumont <[email protected]>
ac557ab
to
2fdf048
Compare
Updated and merged |
@@ -1082,6 +1082,14 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour | |||
accepted = true | |||
irKey := t.getIRKey(listener.gateway) | |||
|
|||
tls := ir.TLS{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldnt this be executed conditionally ?
e.g.
gateway/internal/gatewayapi/listener.go
Line 53 in 33443f8
if listener.TLS != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anything's changed here, previously we set unconditionally:
TLS: &ir.TLS{Terminate: irTLSConfigs(listener.tlsSecrets)},
irTLSConfigs
returns nil
if there aren't any secrets. The line you linked to is also gated by checking the listener protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thanks for the checking!
@michaelbeaumont 'make lint's is failing because of trailing whitespaces, once that's fixed, LGTM from my end ! |
@michaelbeaumont can you also fix DCO and force push ? |
Signed-off-by: Mike Beaumont <[email protected]>
30c4ab6
to
911aa09
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
It would be helpful if we wcould cover two snis on the same port in the xds translation test. But this can be added later.
@zhaohuabing I added another SNI to the test https://github.com/envoyproxy/gateway/pull/2942/files#diff-3481ca7cb1d20b614db1882fa576de2d303d434e519a17d12c2792436d6a0e18R28 actually |
What type of PR is this?
A fix for TLS listener with
hostname
handling.What this PR does / why we need it:
This PR sets
filterChainMatch.serverNames
when using TLS listeners with ahostname
.Which issue(s) this PR fixes: