Skip to content

Commit

Permalink
feat: respone cert issue error
Browse files Browse the repository at this point in the history
  • Loading branch information
pupilcc committed Jan 9, 2024
1 parent 9482002 commit 4e7a9d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions middleware/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func email() {
}
}

func Issue(name string) {
func Issue(name string) error {
logger := GetLogger()
dns := os.Getenv("ACME_DNS")
alias := os.Getenv("ACME_ALIAS")
Expand All @@ -53,9 +53,10 @@ func Issue(name string) {
logger.Error("Running command failed", zap.String("error:", err.Error()))
}
fmt.Printf(string(output))
return err
}

func Install(name string, id string) {
func Install(name string, id string) error {
logger := GetLogger()

cmd := exec.Command(filepath.Join(usr.HomeDir, ".acme.sh/acme.sh"), "--install-cert", "-d", name, "--key-file", filepath.Join(service.CertPath, id+".key"), "--fullchain-file", filepath.Join(service.CertPath, id+".crt"))
Expand All @@ -65,4 +66,5 @@ func Install(name string, id string) {
logger.Error("Running command failed", zap.String("error:", err.Error()))
}
fmt.Printf(string(output))
return err
}
14 changes: 12 additions & 2 deletions web/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ func generate(c echo.Context) error {
fmt.Println("错误:", err)
}

middleware.Issue(certCommand.Domain)
middleware.Install(certCommand.Domain, id)
err = middleware.Issue(certCommand.Domain)
if err != nil {
return err
}

err = middleware.Install(certCommand.Domain, id)
if err != nil {
return err
}
service.SaveUuid(certCommand.Domain, id)
if err != nil {
return err
}

return nil
}

0 comments on commit 4e7a9d3

Please sign in to comment.