SavePrivateKey writes the private key to disk with appropriate permissions
(uuid, privateKey string)
| 29 | |
| 30 | // SavePrivateKey writes the private key to disk with appropriate permissions |
| 31 | func SavePrivateKey(uuid, privateKey string) error { |
| 32 | keyDir, err := ThunderSubdir("keys") |
| 33 | if err != nil { |
| 34 | return fmt.Errorf("failed to create keys directory: %w", err) |
| 35 | } |
| 36 | |
| 37 | keyFile := filepath.Join(keyDir, uuid) |
| 38 | if err := os.WriteFile(keyFile, []byte(privateKey), 0600); err != nil { |
| 39 | return fmt.Errorf("failed to write private key: %w", err) |
| 40 | } |
| 41 | |
| 42 | return nil |
| 43 | } |