MCPcopy Index your code
hub / github.com/Thunder-Compute/thunder-cli / savePrivateKeyToFile

Function savePrivateKeyToFile

utils/ssh_test.go:65–72  ·  view source on GitHub ↗

savePrivateKeyToFile saves an RSA private key to a file in PEM format

(t *testing.T, privateKey *rsa.PrivateKey, path string)

Source from the content-addressed store, hash-verified

63
64// savePrivateKeyToFile saves an RSA private key to a file in PEM format
65func 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.

Calls 1

WriteFileMethod · 0.65

Tested by

no test coverage detected