mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: 解决自签证书使用 RSA 类型秘钥签发证书失败的问题 (#3204)
This commit is contained in:
parent
a463026efe
commit
b6cbca36c2
@ -276,7 +276,7 @@ func (w WebsiteCAService) ObtainSSL(req request.WebsiteCAObtain) (*model.Website
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rootPrivateKey any
|
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)
|
rootPrivateKey, err = x509.ParseECPrivateKey(rootPrivateKeyBlock.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -396,8 +396,7 @@ func createPrivateKey(keyType string) (privateKey any, publicKey any, privateKey
|
|||||||
block.Bytes = privateBytes
|
block.Bytes = privateBytes
|
||||||
_ = pem.Encode(caPrivateKeyPEM, block)
|
_ = pem.Encode(caPrivateKeyPEM, block)
|
||||||
} else {
|
} else {
|
||||||
publicKey = privateKey.(*rsa.PrivateKey).PublicKey
|
publicKey = &privateKey.(*rsa.PrivateKey).PublicKey
|
||||||
publicKey = publicKey.(*rsa.PublicKey)
|
|
||||||
_ = pem.Encode(caPrivateKeyPEM, &pem.Block{
|
_ = pem.Encode(caPrivateKeyPEM, &pem.Block{
|
||||||
Type: "RSA PRIVATE KEY",
|
Type: "RSA PRIVATE KEY",
|
||||||
Bytes: x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)),
|
Bytes: x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)),
|
||||||
|
@ -35,7 +35,7 @@ func (ssl *ssl) Run() {
|
|||||||
expireDate := s.ExpireDate.In(nyc)
|
expireDate := s.ExpireDate.In(nyc)
|
||||||
sub := expireDate.Sub(now)
|
sub := expireDate.Sub(now)
|
||||||
if sub.Hours() < 720 {
|
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 {
|
if s.Provider == constant.SelfSigned {
|
||||||
caService := service.NewIWebsiteCAService()
|
caService := service.NewIWebsiteCAService()
|
||||||
if _, err := caService.ObtainSSL(request.WebsiteCAObtain{
|
if _, err := caService.ObtainSSL(request.WebsiteCAObtain{
|
||||||
@ -43,7 +43,7 @@ func (ssl *ssl) Run() {
|
|||||||
SSLID: s.ID,
|
SSLID: s.ID,
|
||||||
Renew: true,
|
Renew: true,
|
||||||
Unit: "year",
|
Unit: "year",
|
||||||
Time: 1,
|
Time: 10,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
global.LOG.Errorf("Failed to update the SSL certificate for the [%s] domain , err:%s", s.PrimaryDomain, err.Error())
|
global.LOG.Errorf("Failed to update the SSL certificate for the [%s] domain , err:%s", s.PrimaryDomain, err.Error())
|
||||||
continue
|
continue
|
||||||
@ -69,7 +69,7 @@ func (ssl *ssl) Run() {
|
|||||||
continue
|
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")
|
global.LOG.Info("The scheduled certificate update task has completed")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user