Open ferdinandosimonetti opened 4 weeks ago
the only difference between TCPRoute and TLSRoute is an additional TLS Inspector filter that performs a SNI check https://github.com/envoyproxy/gateway/blob/db6802736680a08a210b16085af5a7bf2f124127/internal/xds/translator/testdata/out/xds-ir/tls-route-passthrough.listeners.yaml#L17 cc @cpakulski
I've come to understand the problem: fact is, that PostgreSQL's TLS involves an initial phase in clear when the client issues a STARTTLS request, then the tunnel establishes.
This, however, conflicts with Envoy-side setup, with TLS tunnel already up from its side, and SNI detection.
Sent from Outlook for Androidhttps://aka.ms/AAb9ysg
From: Arko Dasgupta @.> Sent: Friday, November 1, 2024 1:08:19 AM To: envoyproxy/gateway @.> Cc: Ferdinando Simonetti @.>; Author @.> Subject: Re: [envoyproxy/gateway] TLS passthrough Gateway and TLSRoute to SSL-enabled PostgreSQL instance not working (Issue #4594)
the only difference between TCPRoute and TLSRoute is an additional TLS Inspector filter that performs a SNI check https://github.com/envoyproxy/gateway/blob/db6802736680a08a210b16085af5a7bf2f124127/internal/xds/translator/testdata/out/xds-ir/tls-route-passthrough.listeners.yaml#L17 cc @cpakulskihttps://github.com/cpakulski
— Reply to this email directly, view it on GitHubhttps://github.com/envoyproxy/gateway/issues/4594#issuecomment-2451047097, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFHUAS7QLV23ZHEDOQUGS4DZ6LA7HAVCNFSM6AAAAABQ6BBQDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJRGA2DOMBZG4. You are receiving this because you authored the thread.Message ID: @.***>
@ferdinandosimonetti yes, you are correct. I have not initially understood the problem you reported, but after your investigation it is clear why it does not work. Sometime ago I investigated possibility to "wait" with upstream cluster selection (routing) until Envoy completes STARTTLS negotiation with the client, but it was not trivial and work has been put on hold.
hey @cpakulski is there an open issue in envoy proxy that we can link this issue to ?
Not exact, but somehow related: https://github.com/envoyproxy/envoy/issues/32954
@ferdinandosimonetti yes, you are correct. I have not initially understood the problem you reported, but after your investigation it is clear why it does not work. Sometime ago I investigated possibility to "wait" with upstream cluster selection (routing) until Envoy completes STARTTLS negotiation with the client, but it was not trivial and work has been put on hold.
If there would be a way to ask PostgreSQL to listen in TLS mode directly, even on a different port... then I could use several TLSRoutes with a single listener, for reaching the different PostgreSQL environments (dev, stage, prod) exposing a single IP
So far, I haven't been able to understand how it could be possible, and if it could be possible.
I could configure downstream transport socket to be TLS (not STARTTLS), so you could select route based on SNI. But you would need non-standard postgres client, as standard one uses STARTTLS. Or maybe you can construct your client to send postgres traffic in clear and that traffic is forwarded to a socket which implements TLS. In that scenario, you do not even need postgres filter and forwarding in Envoy would only need tcp_proxy.
Description:
Instead, I received a *server closed the connection unexpectedly immediately after trying to connect
I'm working with a VPN, hence I can reach even Gateways with private IPs (my Kubernetes clusters is an Azure AKS one).
I can still reach the same PostgreSQL instance through a TCP-enabled Gateway and TCPRoute (their configurations are shown below).
Repro steps:
Below you can find my EnvoyProxy, GatewayClass, Gateway and TLSRoute
Environment:
I'm using Helm to install Envoy Gateway, the Helm Chart version is v1.1.2 My Kubernetes cluster is an Azure AKS
This other combination of TCP-enabled Gateway and TCPRoute allows me to reach the PostgreSQL instance correctly.
**I had exactly the same results (TLSRoute unreachable, server closed the connection unexpectedly) when I tried to follow the tutorial here
Logs:
Each time I try to connect through the TLS passthrough gateway and TLSRoute I see no log entries (even with debug set for log verbosity)
Here are the kubectl describe outputs for both my TLSRoute and TLS-passthrough enabled Gateway.