admin: Improve CA API
This commit is contained in:
parent
1c879fe50e
commit
91182b1877
2 changed files with 51 additions and 25 deletions
|
|
@ -4,33 +4,32 @@ import (
|
|||
"os/exec"
|
||||
)
|
||||
|
||||
func GenerateCA() string {
|
||||
func convOutput(in []byte, err error) (string, error) {
|
||||
return string(in), err
|
||||
}
|
||||
|
||||
|
||||
func GenerateCA() (string, error) {
|
||||
// Call the script and return its standard and error output
|
||||
cmd := exec.Command("./CA.sh", "-newca")
|
||||
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return string(output) + err.Error()
|
||||
} else {
|
||||
return string(output)
|
||||
}
|
||||
return convOutput(cmd.CombinedOutput())
|
||||
}
|
||||
|
||||
func (t Team) GenerateCert() string {
|
||||
func GenerateCRL() (string, error) {
|
||||
cmd := exec.Command("./CA.sh", "-gencrl")
|
||||
|
||||
return convOutput(cmd.CombinedOutput())
|
||||
}
|
||||
|
||||
func (t Team) GenerateCert() (string, error) {
|
||||
cmd := exec.Command("./CA.sh", "-newclient", t.Name)
|
||||
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return string(output) + err.Error()
|
||||
} else {
|
||||
return string(output)
|
||||
}
|
||||
return convOutput(cmd.CombinedOutput())
|
||||
}
|
||||
|
||||
func (t Team) RevokeCert() string {
|
||||
func (t Team) RevokeCert() (string, error) {
|
||||
cmd := exec.Command("./CA.sh", "-revoke", t.Name)
|
||||
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return string(output) + err.Error()
|
||||
} else {
|
||||
return string(output)
|
||||
}
|
||||
return convOutput(cmd.CombinedOutput())
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue