refactor: only accept certificate as base64, remove cert_path field

- RegisterInput now only has cert_file (base64 content)
- Removed cert_path fallback and raw map parsing
- Clean struct-based JSON unmarshaling
This commit is contained in:
lite 2026-05-19 17:16:48 -04:00
parent 9c4f11d7c7
commit 3ede32ef20
1 changed files with 4 additions and 4 deletions

View File

@ -17,7 +17,7 @@ import (
type RegisterInput struct {
CertName string `json:"cert_name"`
CertFileBase64 string `json:"cert_file"`
CertFile string `json:"cert_file"`
PasswordEncrypted string `json:"password_encrypted"`
}
@ -72,7 +72,7 @@ func (h *Handler) RegisterCert(w http.ResponseWriter, r *http.Request) {
return
}
if input.CertName == "" || input.CertFileBase64 == "" || input.PasswordEncrypted == "" {
if input.CertName == "" || input.CertFile == "" || input.PasswordEncrypted == "" {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"success":false,"error":"missing_fields"}`))
return
@ -94,7 +94,7 @@ func (h *Handler) RegisterCert(w http.ResponseWriter, r *http.Request) {
plainPass := string(plainPassBytes)
validation := cert.ValidateP12(input.CertFileBase64, plainPass)
validation := cert.ValidateP12(input.CertFile, plainPass)
if !validation.Valid {
resp, _ := json.Marshal(map[string]interface{}{
"success": false,
@ -106,7 +106,7 @@ func (h *Handler) RegisterCert(w http.ResponseWriter, r *http.Request) {
return
}
tempPath, err := h.cert.StoreFromBase64(input.CertName, input.CertFileBase64)
tempPath, err := h.cert.StoreFromBase64(input.CertName, input.CertFile)
if err != nil {
h.cert.DeleteTemp(tempPath)
w.Header().Set("Content-Type", "application/json")