|
|
|
@ -509,12 +509,13 @@ class sites(object): |
|
|
|
|
def setSslConf(self, site_name): |
|
|
|
|
file = self.getHostConf(site_name) |
|
|
|
|
conf = mw.readFile(file) |
|
|
|
|
if not conf: |
|
|
|
|
return mw.returnData(False, '站点[%s]配置异常!'.format(site_name)) |
|
|
|
|
|
|
|
|
|
version = mw.getOpVer() |
|
|
|
|
|
|
|
|
|
keyPath = self.sslDir + '/' + site_name + '/privkey.pem' |
|
|
|
|
certPath = self.sslDir + '/' + site_name + '/fullchain.pem' |
|
|
|
|
if conf: |
|
|
|
|
|
|
|
|
|
if conf.find('ssl_certificate') == -1: |
|
|
|
|
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; |
|
|
|
|
# add_header Alt-Svc 'h3=":443";ma=86400,h3-29=":443";ma=86400'; |
|
|
|
@ -559,12 +560,11 @@ class sites(object): |
|
|
|
|
mw.backFile(file) |
|
|
|
|
mw.writeFile(file, conf) |
|
|
|
|
isError = mw.checkWebConfig() |
|
|
|
|
if(isError != True): |
|
|
|
|
if not isError: |
|
|
|
|
mw.restoreFile(file) |
|
|
|
|
return mw.returnData(False, '证书错误: <br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>') |
|
|
|
|
|
|
|
|
|
self.saveCert(keyPath, certPath) |
|
|
|
|
|
|
|
|
|
self.saveCert(site_name, keyPath, certPath) |
|
|
|
|
msg = mw.getInfo('网站[{1}]开启SSL成功!', (site_name,)) |
|
|
|
|
mw.writeLog('网站管理', msg) |
|
|
|
|
|
|
|
|
@ -1758,7 +1758,7 @@ location ^~ {from} {\n\ |
|
|
|
|
} |
|
|
|
|
return mw.returnData(True, 'OK', data) |
|
|
|
|
|
|
|
|
|
def saveCert(self, keyPath, certPath): |
|
|
|
|
def saveCert(self, site_name, keyPath, certPath): |
|
|
|
|
try: |
|
|
|
|
certInfo = mw.getCertName(certPath) |
|
|
|
|
if not certInfo: |
|
|
|
@ -1787,7 +1787,7 @@ location ^~ {from} {\n\ |
|
|
|
|
keyPath = vpath + '/' + d + '/privkey.pem' |
|
|
|
|
certPath = vpath + '/' + d + '/fullchain.pem' |
|
|
|
|
if os.path.exists(keyPath) and os.path.exists(certPath): |
|
|
|
|
self.saveCert(keyPath, certPath) |
|
|
|
|
self.saveCert(d, keyPath, certPath) |
|
|
|
|
|
|
|
|
|
mpath = vpath + '/' + d + '/info.json' |
|
|
|
|
if not os.path.exists(mpath): |
|
|
|
@ -2172,7 +2172,7 @@ location ^~ {from} {\n\ |
|
|
|
|
def createAcmeDns(self, site_name, domains, email, dnspai, wildcard_domain, force, renew): |
|
|
|
|
dnsapi_option = thisdb.getOptionByJson('dnsapi', default={}) |
|
|
|
|
if not dnspai in dnsapi_option: |
|
|
|
|
return mw.returnData(False, dnspai+'未设置') |
|
|
|
|
return mw.returnData(False, '['+dnspai+']未设置!') |
|
|
|
|
|
|
|
|
|
dnsapi_data = dnsapi_option[dnspai] |
|
|
|
|
for k in dnsapi_data: |
|
|
|
|