From 8a60965069b6995c951f41ac9dd37da2da3e263b Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sun, 26 May 2024 22:50:29 +0800 Subject: [PATCH] update --- class/core/config_api.py | 31 ++++++++++++++++++++----------- route/static/app/config.js | 13 +++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index 81971f662..419e2aa53 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -362,20 +362,23 @@ class config_api: return mw.getJson(cert) def getPanelSslData(self): - cert = {} + rdata = {} + choose_file = self.__file['ssl'] + rdata['choose'] = mw.readFile(choose_file) + + keyPath = 'ssl/local/private.pem' certPath = 'ssl/local/cert.pem' if not os.path.exists(certPath): - # 不再自动生成证书 mw.createLocalSSL() - cert['privateKey'] = '' - cert['is_https'] = '' - cert['certPem'] = '' - cert['rep'] = os.path.exists('ssl/local/input.pl') - cert['info'] = mw.getCertName(certPath) - # cert['info'] = {'endtime': 0, 'subject': '无','notAfter': '无', 'notBefore': '无', 'issuer': '无'} - return cert + + cert = {} + cert['privateKey'] = mw.readFile(keyPath) + cert['is_https'] = '' + cert['certPem'] = mw.readFile(certPath) + cert['info'] = mw.getCertName(certPath) + rdata['local'] = cert panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf" if not os.path.exists(panel_ssl): @@ -385,11 +388,17 @@ class config_api: if ssl_data.find('$server_port !~ 443') != -1: cert['is_https'] = 'checked' + keyPath = 'ssl/nginx/private.pem' + certPath = 'ssl/nginx/cert.pem' + + cert = {} cert['privateKey'] = mw.readFile(keyPath) cert['certPem'] = mw.readFile(certPath) - cert['rep'] = os.path.exists('ssl/input.pl') cert['info'] = mw.getCertName(certPath) - return cert + + rdata['nginx'] = cert + + return rdata # 面板本地SSL设置 def setPanelLocalSslApi(self): diff --git a/route/static/app/config.js b/route/static/app/config.js index 3fa6ad270..fd70dbcda 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -804,6 +804,19 @@ function getPanelSSL(){ $.post('/config/get_panel_ssl',{},function(cert){ layer.close(loadT); + console.log(cert); + + var choose = cert['choose']; + + if (choose == 'local'){ + cert = cert['local']; + } else if (choose == 'nginx') { + cert = cert['nginx']; + } else { + layer.msg("无效配置"); + return; + } + var cert_data = ''; if (cert['info']){