savePrivateKeyToFile saves an RSA private key to a file in PEM format
(t *testing.T, privateKey *rsa.PrivateKey, path string)
| 63 | |
| 64 | // savePrivateKeyToFile saves an RSA private key to a file in PEM format |
| 65 | func savePrivateKeyToFile(t *testing.T, privateKey *rsa.PrivateKey, path string) { |
| 66 | der := x509.MarshalPKCS1PrivateKey(privateKey) |
| 67 | pemBlock := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: der} |
| 68 | keyData := pem.EncodeToMemory(pemBlock) |
| 69 | |
| 70 | err := os.WriteFile(path, keyData, 0600) |
| 71 | require.NoError(t, err) |
| 72 | } |
| 73 | |
| 74 | // setupSSHTestServer creates and starts an SSH test server that accepts connections |
| 75 | // using the provided client public key. Returns the server instance and a cleanup function. |
no test coverage detected