Skip to content

Commit

Permalink
fix: cert install folder not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
pupilcc committed Jan 9, 2024
1 parent 77dc30f commit 19e2d94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion middleware/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package middleware

import (
"autossl/internal/service"
"fmt"
"go.uber.org/zap"
"os"
"os/exec"
Expand Down Expand Up @@ -56,10 +57,15 @@ func Issue(name string) {

func Install(name string, id string) {
logger := GetLogger()
err := os.MkdirAll(service.CertPath, 0755)
if err != nil {
fmt.Println("错误:", err)
}

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"))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
err := cmd.Start()
err = cmd.Start()
if err != nil {
logger.Error("cmd.Start() failed with %s\n", zap.String("error", err.Error()))
}
Expand Down

0 comments on commit 19e2d94

Please sign in to comment.