auto generate cert keys

This commit is contained in:
Alireza Ahmadi
2024-06-13 20:16:04 +02:00
parent d057076251
commit b144aecb6a
11 changed files with 215 additions and 20 deletions
+20
View File
@@ -159,3 +159,23 @@ func (s *ServerService) GetLogs(service string, count string, level string) []st
return lines
}
func (s *ServerService) GenKeypair(keyType string, options string) []string {
if len(keyType) == 0 {
return []string{"No keypair to generate"}
}
sbExec := s.GetBinaryPath()
cmdArgs := []string{"generate", keyType + "-keypair"}
if keyType == "tls" || keyType == "ech" {
cmdArgs = append(cmdArgs, options)
}
// Run the command
cmd := exec.Command(sbExec, cmdArgs...)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return []string{"Failed to generate keypair"}
}
return strings.Split(out.String(), "\n")
}