admin: allow certid to finish by .p12, to permit downloading .p12 file

This commit is contained in:
nemunaire 2019-02-05 01:45:19 +01:00
parent 703eaef880
commit b778d29dd9
3 changed files with 4 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"time"
"srs.epita.fr/fic-server/libfic"
@ -317,7 +318,7 @@ func fileHandler(f func(fic.EFile, []byte) (interface{}, error)) func(httprouter
func certificateHandler(f func(fic.Certificate, []byte) (interface{}, error)) func(httprouter.Params, []byte) (interface{}, error) {
return func(ps httprouter.Params, body []byte) (interface{}, error) {
if certid, err := strconv.ParseUint(string(ps.ByName("certid")), 10, 64); err != nil {
if certid, err := strconv.ParseUint(strings.TrimSuffix(string(ps.ByName("certid")), ".p12"), 10, 64); err != nil {
return nil, err
} else if cert, err := fic.GetCertificate(certid); err != nil {
return nil, err