Add certificate generation and revokation

This commit is contained in:
nemunaire 2016-01-20 19:56:08 +01:00
commit ede5bb18b1
8 changed files with 577 additions and 2 deletions

36
libfic/certificate.go Normal file
View file

@ -0,0 +1,36 @@
package fic
import (
"os/exec"
)
func GenerateCA() string {
// 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)
}
}
func (t Team) GenerateCert() string {
cmd := exec.Command("./CA.sh", "-newclient", t.Name)
if output, err := cmd.CombinedOutput(); err != nil {
return string(output) + err.Error()
} else {
return string(output)
}
}
func (t Team) RevokeCert() string {
cmd := exec.Command("./CA.sh", "-revoke", t.Name)
if output, err := cmd.CombinedOutput(); err != nil {
return string(output) + err.Error()
} else {
return string(output)
}
}