From b6cbca36c218471dc1ca38b9701a200c437885c2 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:42:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=87=AA=E7=AD=BE?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E4=BD=BF=E7=94=A8=20RSA=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=A7=98=E9=92=A5=E7=AD=BE=E5=8F=91=E8=AF=81=E4=B9=A6=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#3204)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/website_ca.go | 5 ++--- backend/cron/job/ssl.go | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/app/service/website_ca.go b/backend/app/service/website_ca.go index 15bb9abad..40bdcb5c7 100644 --- a/backend/app/service/website_ca.go +++ b/backend/app/service/website_ca.go @@ -276,7 +276,7 @@ func (w WebsiteCAService) ObtainSSL(req request.WebsiteCAObtain) (*model.Website } var rootPrivateKey any - if ssl.KeyType(websiteSSL.KeyType) == certcrypto.EC256 || ssl.KeyType(websiteSSL.KeyType) == certcrypto.EC384 { + if ssl.KeyType(ca.KeyType) == certcrypto.EC256 || ssl.KeyType(ca.KeyType) == certcrypto.EC384 { rootPrivateKey, err = x509.ParseECPrivateKey(rootPrivateKeyBlock.Bytes) if err != nil { return nil, err @@ -396,8 +396,7 @@ func createPrivateKey(keyType string) (privateKey any, publicKey any, privateKey block.Bytes = privateBytes _ = pem.Encode(caPrivateKeyPEM, block) } else { - publicKey = privateKey.(*rsa.PrivateKey).PublicKey - publicKey = publicKey.(*rsa.PublicKey) + publicKey = &privateKey.(*rsa.PrivateKey).PublicKey _ = pem.Encode(caPrivateKeyPEM, &pem.Block{ Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)), diff --git a/backend/cron/job/ssl.go b/backend/cron/job/ssl.go index 1256fcf1d..374d45664 100644 --- a/backend/cron/job/ssl.go +++ b/backend/cron/job/ssl.go @@ -35,7 +35,7 @@ func (ssl *ssl) Run() { expireDate := s.ExpireDate.In(nyc) sub := expireDate.Sub(now) if sub.Hours() < 720 { - global.LOG.Errorf("Update the SSL certificate for the [%s] domain", s.PrimaryDomain) + global.LOG.Infof("Update the SSL certificate for the [%s] domain", s.PrimaryDomain) if s.Provider == constant.SelfSigned { caService := service.NewIWebsiteCAService() if _, err := caService.ObtainSSL(request.WebsiteCAObtain{ @@ -43,7 +43,7 @@ func (ssl *ssl) Run() { SSLID: s.ID, Renew: true, Unit: "year", - Time: 1, + Time: 10, }); err != nil { global.LOG.Errorf("Failed to update the SSL certificate for the [%s] domain , err:%s", s.PrimaryDomain, err.Error()) continue @@ -69,7 +69,7 @@ func (ssl *ssl) Run() { continue } } - global.LOG.Errorf("The SSL certificate for the [%s] domain has been successfully updated", s.PrimaryDomain) + global.LOG.Infof("The SSL certificate for the [%s] domain has been successfully updated", s.PrimaryDomain) } } global.LOG.Info("The scheduled certificate update task has completed")