Skip to content

Commit

Permalink
feat: checked cert exist
Browse files Browse the repository at this point in the history
  • Loading branch information
pupilcc committed Jan 9, 2024
1 parent 4e7a9d3 commit f91d296
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/service/ssl_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func AddCert(name string, certFile *multipart.FileHeader, keyFile *multipart.Fil
if certs != nil {
for _, cert := range certs {
if cert.Name == name {
return fmt.Errorf("cert %s already exist", name)
return fmt.Errorf("certificate %s already exist", name)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions web/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ func generate(c echo.Context) error {
return err
}

certs := service.GetCerts()
if certs != nil {
for _, cert := range certs {
if cert.Name == certCommand.Domain {
return fmt.Errorf("certificate %s already exist", certCommand.Domain)
}
}
}

id := util.GenerateID()

err := os.MkdirAll(service.CertPath, 0755)
Expand All @@ -111,5 +120,6 @@ func generate(c echo.Context) error {
return err
}

_ = c.JSON(http.StatusOK, response.Message(certCommand.Domain+" Certificate generated successfully."))
return nil
}

0 comments on commit f91d296

Please sign in to comment.