Skip to content

Commit

Permalink
update tsh kube proxy key algorithm (#47240)
Browse files Browse the repository at this point in the history
  • Loading branch information
nklaassen authored Oct 8, 2024
1 parent 1952dd8 commit 4465852
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tool/tsh/common/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import (
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils/keys"
"github.com/gravitational/teleport/lib/asciitable"
"github.com/gravitational/teleport/lib/auth/native"
"github.com/gravitational/teleport/lib/client"
kubeclient "github.com/gravitational/teleport/lib/client/kube"
"github.com/gravitational/teleport/lib/cryptosuites"
"github.com/gravitational/teleport/lib/kube/kubeconfig"
"github.com/gravitational/teleport/lib/srv/alpnproxy"
"github.com/gravitational/teleport/lib/utils"
Expand Down Expand Up @@ -315,7 +315,11 @@ func makeKubeLocalProxy(cf *CLIConf, tc *client.TeleportClient, clusters kubecon

// Generate a new private key for the proxy. The client's existing private key may be
// a hardware-backed private key, which cannot be added to the local proxy kube config.
localClientKey, err := native.GeneratePrivateKey()
key, err := cryptosuites.GenerateKey(cf.Context, tc.GetCurrentSignatureAlgorithmSuite, cryptosuites.UserTLS)
if err != nil {
return nil, trace.Wrap(err)
}
localClientKey, err := keys.NewSoftwarePrivateKey(key)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down
7 changes: 7 additions & 0 deletions tool/tsh/common/kube_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package common
import (
"bytes"
"context"
"crypto/ecdsa"
"fmt"
"io"
"net/http"
Expand All @@ -44,6 +45,7 @@ import (

"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils/keypaths"
"github.com/gravitational/teleport/api/utils/keys"
"github.com/gravitational/teleport/lib/kube/kubeconfig"
"github.com/gravitational/teleport/lib/srv/alpnproxy/common"
)
Expand Down Expand Up @@ -133,6 +135,11 @@ func sendRequestToKubeLocalProxy(t *testing.T, config *clientcmdapi.Config, tele
proxyURL, err := url.Parse(config.Clusters[contextName].ProxyURL)
require.NoError(t, err)

// Sanity check we're using an ECDSA client key.
key, err := keys.ParsePrivateKey(config.AuthInfos[contextName].ClientKeyData)
require.NoError(t, err)
require.IsType(t, (*ecdsa.PrivateKey)(nil), key.Signer)

tlsClientConfig := rest.TLSClientConfig{
CAData: config.Clusters[contextName].CertificateAuthorityData,
CertData: config.AuthInfos[contextName].ClientCertificateData,
Expand Down

0 comments on commit 4465852

Please sign in to comment.