Skip to content

Commit

Permalink
feat: 移除面板证书续签并将证书有效期固定为10年
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jan 2, 2025
1 parent 645a6d2 commit d6b016d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
18 changes: 0 additions & 18 deletions internal/job/cert_renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package job

import (
"log/slog"
"path/filepath"
"time"

"gorm.io/gorm"

"github.com/tnb-labs/panel/internal/app"
"github.com/tnb-labs/panel/internal/biz"
pkgcert "github.com/tnb-labs/panel/pkg/cert"
"github.com/tnb-labs/panel/pkg/io"
"github.com/tnb-labs/panel/pkg/shell"
)

// CertRenew 证书续签
Expand Down Expand Up @@ -60,19 +57,4 @@ func (r *CertRenew) Run() {
r.log.Warn("[Cert Renew] failed to renew cert", slog.Any("err", err))
}
}

// 续签面板证书
panelCert, err := io.Read(filepath.Join(app.Root, "panel/storage/cert.pem"))
if err != nil {
r.log.Warn("[Cert Renew] failed to read panel cert", slog.Any("err", err))
return
}
decode, err := pkgcert.ParseCert(panelCert)
if err != nil {
r.log.Warn("[Cert Renew] failed to parse panel cert", slog.Any("err", err))
return
}
if time.Until(decode.NotAfter) < 24*7*time.Hour {
_, _ = shell.Exec("panel-cli https generate")
}
}
4 changes: 2 additions & 2 deletions pkg/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func GenerateSelfSigned(names []string) (cert []byte, key []byte, err error) {
SerialNumber: big.NewInt(2),
Subject: pkix.Name{CommonName: "Rat Panel CA"},
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(3, 0, 0),
NotAfter: time.Now().AddDate(10, 0, 0),
BasicConstraintsValid: true,
IsCA: true,
KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageDigitalSignature,
Expand All @@ -167,7 +167,7 @@ func GenerateSelfSigned(names []string) (cert []byte, key []byte, err error) {
SerialNumber: big.NewInt(3),
Subject: pkix.Name{CommonName: "Rat Panel"},
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(1, 0, 0),
NotAfter: time.Now().AddDate(10, 0, 0),
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
}
Expand Down

0 comments on commit d6b016d

Please sign in to comment.