From e6526fb780478908b67bee0555e8e65e9cb87ccf Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Mon, 21 Jul 2025 22:11:04 +0700 Subject: [PATCH] added createrootcertificateifnotexists --- api/RootCert.go | 10 +- api/frontend/index.html | 112 +++++++++++++++-------- api/frontend/js/rootcrt.js | 65 +++++++++++++ model/CreateRootCertRequest.go | 20 ++-- server/Configure.go | 2 - utils/CheckOrCreateRootKeyCertificate.go | 50 ---------- utils/CreateRootKeyCertificate.go | 23 ++--- utils/LoadRootCertAndKey.go | 1 - 8 files changed, 169 insertions(+), 114 deletions(-) create mode 100644 api/frontend/js/rootcrt.js delete mode 100644 utils/CheckOrCreateRootKeyCertificate.go diff --git a/api/RootCert.go b/api/RootCert.go index ce031c3..16ac286 100644 --- a/api/RootCert.go +++ b/api/RootCert.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "scm/model" + "scm/utils" ) func RootCert(w http.ResponseWriter, r *http.Request) { @@ -16,7 +17,6 @@ func RootCert(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - fmt.Fprintf(w, `{"status":"ok"}`) case "POST": var rootCertRequest model.CreateRootCertRequest @@ -25,9 +25,11 @@ func RootCert(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } - - - + err = utils.CreateRootKeyCertificate(rootCertRequest) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } fmt.Fprintf(w, `{"status":"ok"}`) default: http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) diff --git a/api/frontend/index.html b/api/frontend/index.html index 800d4ba..15f0af2 100644 --- a/api/frontend/index.html +++ b/api/frontend/index.html @@ -8,6 +8,7 @@ + Scm