Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/teleterm/gateway/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func (k *kube) makeALPNLocalProxyForKube(cas map[string]tls.Certificate) error {
return trace.NewAggregate(err, listener.Close())
}

webProxyHost, err := utils.Host(k.cfg.WebProxyAddr)
if err != nil {
return trace.Wrap(err)
}

k.localProxy, err = alpnproxy.NewLocalProxy(alpnproxy.LocalProxyConfig{
InsecureSkipVerify: k.cfg.Insecure,
RemoteProxyAddr: k.cfg.WebProxyAddr,
Expand All @@ -107,7 +112,7 @@ func (k *kube) makeALPNLocalProxyForKube(cas map[string]tls.Certificate) error {
ALPNConnUpgradeRequired: k.cfg.TLSRoutingConnUpgradeRequired,
},
alpnproxy.WithHTTPMiddleware(middleware),
alpnproxy.WithSNI(client.GetKubeTLSServerName(k.cfg.WebProxyAddr)),
alpnproxy.WithSNI(client.GetKubeTLSServerName(webProxyHost)),
alpnproxy.WithClusterCAs(k.closeContext, k.cfg.RootClusterCACertPoolFunc),
)
if err != nil {
Expand Down
10 changes: 7 additions & 3 deletions lib/teleterm/gateway/kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,20 @@ func mustStartMockProxyWithKubeAPI(t *testing.T, identity tlsca.Identity) *mockP
return m
}

func mustGenCAForProxyKubeAddr(t *testing.T, key *keys.PrivateKey, host string) (tls.Certificate, *tlsca.CertAuthority) {
func mustGenCAForProxyKubeAddr(t *testing.T, key *keys.PrivateKey, hostAddr string) (tls.Certificate, *tlsca.CertAuthority) {
t.Helper()

addr, err := utils.ParseAddr(hostAddr)
require.NoError(t, err)

certPem, err := tlsca.GenerateSelfSignedCAWithConfig(tlsca.GenerateCAConfig{
Entity: pkix.Name{
CommonName: "localhost",
Organization: []string{"Teleport"},
},
Signer: key,
DNSNames: []string{client.GetKubeTLSServerName(host)}, // Use special kube SNI.
Signer: key,
// Use special kube SNI. Make sure only host (no port) is used.
DNSNames: []string{client.GetKubeTLSServerName(addr.Host())},
TTL: defaults.CATTL,
})
require.NoError(t, err)
Expand Down