MCPcopy Index your code
hub / github.com/tailscale/tailscale / generateClientKey

Function generateClientKey

ssh/tailssh/tailssh_integration_test.go:847–870  ·  view source on GitHub ↗
(t *testing.T, privateKeyFile string)

Source from the content-addressed store, hash-verified

845}
846
847func generateClientKey(t *testing.T, privateKeyFile string) (ssh.Signer, *rsa.PrivateKey) {
848 t.Helper()
849 priv, err := rsa.GenerateKey(rand.Reader, 2048)
850 if err != nil {
851 t.Fatal(err)
852 }
853 mk, err := x509.MarshalPKCS8PrivateKey(priv)
854 if err != nil {
855 t.Fatal(err)
856 }
857 privateKey := pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: mk})
858 if privateKey == nil {
859 t.Fatal("failed to encoded private key")
860 }
861 err = os.WriteFile(privateKeyFile, privateKey, 0600)
862 if err != nil {
863 t.Fatal(err)
864 }
865 signer, err := ssh.ParsePrivateKey(privateKey)
866 if err != nil {
867 t.Fatal(err)
868 }
869 return signer, priv
870}
871
872// testBackend implements ipnLocalBackend
873type testBackend struct {

Callers 1

TestSSHAgentForwardingFunction · 0.85

Calls 3

HelperMethod · 0.65
FatalMethod · 0.65
WriteFileMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…