From 45d628838f32f50d79107c183a4fa28d680f7714 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:38:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=8E=B7=E5=8F=96=20S?= =?UTF-8?q?SL=20=E4=BF=A1=E6=81=AF=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#5347)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #5339 --- backend/app/service/setting.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go index 914b18459..f32886e65 100644 --- a/backend/app/service/setting.go +++ b/backend/app/service/setting.go @@ -347,7 +347,7 @@ func (u *SettingService) LoadFromCert() (*dto.SSLInfo, error) { if err != nil { return nil, err } - var data *dto.SSLInfo + var data dto.SSLInfo switch sslType.Value { case "self": data, err = loadInfoFromCert() @@ -380,11 +380,11 @@ func (u *SettingService) LoadFromCert() (*dto.SSLInfo, error) { if err != nil { return nil, err } - data.Timeout = ssl.ExpireDate.Format("2006-01-02 15:04:05") data.Domain = ssl.Domains data.SSLID = uint(id) + data.Timeout = ssl.ExpireDate.Format("2006-01-02 15:04:05") } - return data, nil + return &data, nil } func (u *SettingService) HandlePasswordExpired(c *gin.Context, old, new string) error { @@ -426,23 +426,23 @@ func (u *SettingService) UpdatePassword(c *gin.Context, old, new string) error { return nil } -func loadInfoFromCert() (*dto.SSLInfo, error) { +func loadInfoFromCert() (dto.SSLInfo, error) { var info dto.SSLInfo certFile := path.Join(global.CONF.System.BaseDir, "1panel/secret/server.crt") if _, err := os.Stat(certFile); err != nil { - return &info, err + return info, err } certData, err := os.ReadFile(certFile) if err != nil { - return &info, err + return info, err } certBlock, _ := pem.Decode(certData) if certBlock == nil { - return &info, err + return info, err } certObj, err := x509.ParseCertificate(certBlock.Bytes) if err != nil { - return &info, err + return info, err } var domains []string if len(certObj.IPAddresses) != 0 { @@ -453,7 +453,7 @@ func loadInfoFromCert() (*dto.SSLInfo, error) { if len(certObj.DNSNames) != 0 { domains = append(domains, certObj.DNSNames...) } - return &dto.SSLInfo{ + return dto.SSLInfo{ Domain: strings.Join(domains, ","), Timeout: certObj.NotAfter.Format("2006-01-02 15:04:05"), RootPath: path.Join(global.CONF.System.BaseDir, "1panel/secret/server.crt"),