@@ -1759,14 +1759,8 @@ type terminatingGatewayFilterChainOpts struct {
1759
1759
}
1760
1760
1761
1761
func (s * ResourceGenerator ) makeFilterChainTerminatingGateway (cfgSnap * proxycfg.ConfigSnapshot , tgtwyOpts terminatingGatewayFilterChainOpts ) (* envoy_listener_v3.FilterChain , error ) {
1762
- // We need to at least match the SNI and use the root PEMs from the local cluster; however, requests coming
1763
- // from peered clusters where the external service is exported to will have their own SNI and root PEMs.
1762
+ // We need to at least match the SNI and use the root PEMs from the local cluster
1764
1763
sniMatches := []string {tgtwyOpts .cluster }
1765
- for _ , bundle := range tgtwyOpts .peerTrustBundles {
1766
- svc := tgtwyOpts .service
1767
- sourceSNI := connect .PeeredServiceSNI (svc .Name , svc .NamespaceOrDefault (), svc .PartitionOrDefault (), bundle .PeerName , cfgSnap .Roots .TrustDomain )
1768
- sniMatches = append (sniMatches , sourceSNI )
1769
- }
1770
1764
1771
1765
tlsContext := & envoy_tls_v3.DownstreamTlsContext {
1772
1766
CommonTlsContext : makeCommonTLSContext (
@@ -1777,9 +1771,19 @@ func (s *ResourceGenerator) makeFilterChainTerminatingGateway(cfgSnap *proxycfg.
1777
1771
RequireClientCertificate : & wrapperspb.BoolValue {Value : true },
1778
1772
}
1779
1773
1780
- err := injectSpiffeValidatorConfigForPeers (cfgSnap , tlsContext .CommonTlsContext , tgtwyOpts .peerTrustBundles )
1781
- if err != nil {
1782
- return nil , err
1774
+ // For TCP connections, TLS is not terminated at the mesh gateway but is instead proxied through;
1775
+ // therefore, we need to account for callers from other datacenters when setting up our filter chain.
1776
+ if tgtwyOpts .protocol == "tcp" {
1777
+ for _ , bundle := range tgtwyOpts .peerTrustBundles {
1778
+ svc := tgtwyOpts .service
1779
+ sourceSNI := connect .PeeredServiceSNI (svc .Name , svc .NamespaceOrDefault (), svc .PartitionOrDefault (), bundle .PeerName , cfgSnap .Roots .TrustDomain )
1780
+ sniMatches = append (sniMatches , sourceSNI )
1781
+ }
1782
+
1783
+ err := injectSpiffeValidatorConfigForPeers (cfgSnap , tlsContext .CommonTlsContext , tgtwyOpts .peerTrustBundles )
1784
+ if err != nil {
1785
+ return nil , err
1786
+ }
1783
1787
}
1784
1788
1785
1789
transportSocket , err := makeDownstreamTLSTransportSocket (tlsContext )
0 commit comments