Add certificate generation and revokation
This commit is contained in:
parent
9324f6f5fa
commit
ede5bb18b1
8 changed files with 577 additions and 2 deletions
32
admin/api_certificate.go
Normal file
32
admin/api_certificate.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func CertificateAPI(team fic.Team, args []string) (interface{}, error) {
|
||||
if len(args) == 1 {
|
||||
if args[0] == "generate" {
|
||||
return team.GenerateCert(), nil
|
||||
} else if args[0] == "revoke" {
|
||||
return team.RevokeCert(), nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
} else if fd, err := os.Open("../PKI/pkcs/" + team.Name + ".p12"); err == nil {
|
||||
return ioutil.ReadAll(fd)
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var ApiCARouting = map[string]DispatchFunction{
|
||||
"GET": genCA,
|
||||
}
|
||||
|
||||
func genCA(args []string, body []byte) (interface{}, error) {
|
||||
return fic.GenerateCA(), nil
|
||||
}
|
Reference in a new issue