diff --git a/backend/app/dto/setting.go b/backend/app/dto/setting.go
index 866734261..5da1a3dc0 100644
--- a/backend/app/dto/setting.go
+++ b/backend/app/dto/setting.go
@@ -60,7 +60,7 @@ type SettingUpdate struct {
}
type SSLUpdate struct {
- SSLType string `json:"sslType"`
+ SSLType string `json:"sslType" validate:"required,oneof=self select import-paste import-local"`
Domain string `json:"domain"`
SSL string `json:"ssl" validate:"required,oneof=enable disable"`
Cert string `json:"cert"`
diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go
index 6c5cf55b4..d7192145f 100644
--- a/backend/app/service/setting.go
+++ b/backend/app/service/setting.go
@@ -174,6 +174,7 @@ func (u *SettingService) UpdatePort(port uint) error {
return err
}
go func() {
+ time.Sleep(1 * time.Second)
_, err := cmd.Exec("systemctl restart 1panel.service")
if err != nil {
global.LOG.Errorf("restart system port failed, err: %v", err)
@@ -249,9 +250,20 @@ func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error {
if err := settingRepo.Update("SSLID", strconv.Itoa(int(req.SSLID))); err != nil {
return err
}
- case "import":
+ case "import-paste":
secret = req.Cert
key = req.Key
+ case "import-local":
+ keyFile, err := os.ReadFile(req.Key)
+ if err != nil {
+ return err
+ }
+ key = string(keyFile)
+ certFile, err := os.ReadFile(req.Cert)
+ if err != nil {
+ return err
+ }
+ secret = string(certFile)
}
fileOp := files.NewFileOp()
@@ -274,6 +286,7 @@ func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error {
return err
}
go func() {
+ time.Sleep(1 * time.Second)
_, err := cmd.Exec("systemctl restart 1panel.service")
if err != nil {
global.LOG.Errorf("restart system failed, err: %v", err)
diff --git a/frontend/src/views/setting/safe/index.vue b/frontend/src/views/setting/safe/index.vue
index b04a1ade4..3f43b2746 100644
--- a/frontend/src/views/setting/safe/index.vue
+++ b/frontend/src/views/setting/safe/index.vue
@@ -299,7 +299,7 @@ const handleSSL = async () => {
type: 'info',
})
.then(async () => {
- await updateSSL({ ssl: 'disable', domain: '', sslType: '', key: '', cert: '', sslID: 0 });
+ await updateSSL({ ssl: 'disable', domain: '', sslType: form.sslType, key: '', cert: '', sslID: 0 });
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
let href = window.location.href;
globalStore.isLogin = false;
diff --git a/frontend/src/views/setting/safe/ssl/index.vue b/frontend/src/views/setting/safe/ssl/index.vue
index b110ec287..efc5c0dde 100644
--- a/frontend/src/views/setting/safe/ssl/index.vue
+++ b/frontend/src/views/setting/safe/ssl/index.vue
@@ -30,6 +30,12 @@
{{ $t('setting.selfSignedHelper') }}
+