From 3ede32ef20842cf88899f4da0779934bbc97a88f Mon Sep 17 00:00:00 2001 From: lite Date: Tue, 19 May 2026 17:16:48 -0400 Subject: [PATCH] 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 --- api/handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/handler.go b/api/handler.go index a048d88..07a69a5 100644 --- a/api/handler.go +++ b/api/handler.go @@ -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")