(t *testing.T, privateKeyFile string)
| 845 | } |
| 846 | |
| 847 | func 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 |
| 873 | type testBackend struct { |
no test coverage detected
searching dependent graphs…