(sshKey string)
| 473 | } |
| 474 | |
| 475 | func rpcSetSSHKeyState(sshKey string) error { |
| 476 | if sshKey == "" { |
| 477 | // Remove SSH key file if empty string is provided |
| 478 | if err := os.Remove(sshKeyFile); err != nil && !os.IsNotExist(err) { |
| 479 | return fmt.Errorf("failed to remove SSH key file: %w", err) |
| 480 | } |
| 481 | return nil |
| 482 | } |
| 483 | |
| 484 | // Validate SSH key |
| 485 | if err := utils.ValidateSSHKey(sshKey); err != nil { |
| 486 | return err |
| 487 | } |
| 488 | |
| 489 | // Create directory if it doesn't exist |
| 490 | if err := os.MkdirAll(sshKeyDir, 0700); err != nil { |
| 491 | return fmt.Errorf("failed to create SSH key directory: %w", err) |
| 492 | } |
| 493 | |
| 494 | // Write SSH key to file |
| 495 | if err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600); err != nil { |
| 496 | return fmt.Errorf("failed to write SSH key: %w", err) |
| 497 | } |
| 498 | |
| 499 | return nil |
| 500 | } |
| 501 | |
| 502 | func rpcGetTLSState() TLSState { |
| 503 | return getTLSState() |
nothing calls this directly
no test coverage detected